|
thanks for your advice
I dont want to override but the method createLeafElemenmt() and createdefaultroot() are not visible when I want to use them directly.
With the following object D1 the methods are not visible.
PlainDocument D1 = new PlainDocument();
Thanks for your time
|
|
|
|
|
The example I gave should work as it calls the protected method on the super class.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
yes it does do the needful
but why are the methods not visible in the subclasses
protected methods should be visible in subclasses,is it not?
thanks
prithaa
|
|
|
|
|
Read this[^] to understand access modifiers. If something is protected it is visible within the package and to any sub-classes. By being visible to the sub-classes, it can be called from the class, but not from classes referencing the class.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
|
I'm in the process of making the specifications for a project that i have to make at my university. The main topic is distributed systems. I've decided to make a distributed anti spam network.
By this i mean:
* Peer-to-peer network
* Each node can request / respond to queries about email identification signatures
* A catalogue of nodes and email signatures are stored locally with each peer
Now i'm just concerned if this could be defined as a distributed system or if it is just a network?
I hope you can answer my question.
Thanks
|
|
|
|
|
You could use Wikipedia as a reference for Distributed Computing[^]:
The computers interact with each other in order to achieve a common goal.
I guess that's the definition.
|
|
|
|
|
Hi every body,,
I write an app on android and i want send a string with sms to my server, because my length of string is bigger than one sms, i have to compress sms and send to my server, in my server i have a app that wrote with .net, and my problem in here!!!
I can`t find a solution for compress data in Android(Java) and decompress in C#....
Please Help......
|
|
|
|
|
you can't find a solution means you can't find a code that is already written in C# and Java, right?
first you should try to reduce the amount of data in that SMS-String. Can values be resized?
For example can you use integers instead of keywords? Every fixed value can be melted down to a short form (acronyms, integer, single char, char/int compbination, ...).
Are there enum in there -> also usable as integer.
141 characters is a lot of data - and to use an old phrase: "141 characters should be enough for everybody".
|
|
|
|
|
Law of diminishing returns.
The SMS limit is very low. Compression requires overhead. Consequently normal compression is unlikely to save space.
Generalizing the other response.
You want to send a message which has content A.
Your first step should be to look at A and find a different way to send the same information which takes less room.
For example say you want to send
item="purple pants"
Steps to reduce above.
1. Create table of common terms (can't be too big
2. Change above to the following
i40,57
|
|
|
|
|
I am a newbie in J2EE. I have installed NetBeans 7.01 package with GlassFish 3.1.1 (and Tomcat 7.0.14). By default NetBeans starts up the GlassFish server whenever I launch a web app. What should I change if I want to use Tomcat, instead of GlassFish with NetBeans? Thanks!
Best,
Jun
modified 6-Dec-11 15:29pm.
|
|
|
|
|
You need to right click the project go to the properties. Under Run you can select which application server you want to deploy the project to.
|
|
|
|
|
In fact, when you're creating your new J2EE project, you've got the option to define where you've installed the App. Server desired for your project, in order to allow the IDE to build the specific artefact with its deployment descriptors.
|
|
|
|
|
I am building an interface that will be run only locally on users computers using HTML (no web servers involved). What I'd like to do as part of this project is to be able to list the contents of local folders related to this project. Meaning I have a parent folder that will contain all the HTML pages as well as folders with PDF files in them. From my main page I'd like to have a link to those folders and when visited, that link would list the files in that folder. This way, when additional files are added or when files are deleted, the listing will reflect the actual folder contents. Right now this works by linking to the folders and getting the raw Directory listing but the listings are not pretty. I am looking for a more elegant way to achieve this.
Anyone know how to do this with HTML or Javascript?
Thanks,
Craig
|
|
|
|
|
Quite possibly, but this is the Java forum.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I would use a CMS. No need to develop that yourself.
try WebsiteBaker[^] as a simple CMS for small projects.
|
|
|
|
|
|
what are the coding is right for out put visualisation hanoi tower in netbeans?
import java.awt.*;
import javax.swing.*;
import no.geosoft.cc.graphics.*;
/**
* G demo program. Demonstrates:
*
*
* - A sample game application
* - Graphics animation
* - GObject reparenting
*
*
* @author Jacob Dreyer
*/
public class Demo14 extends JFrame
{
private TowersOfHanoi towersOfHanoi_;
private GWindow window_;
private Peg[] pegs_;
private int nDiscs_;
private JButton startButton_;
public Demo14 (int nDiscs)
{
super ("G Graphics Library - Demo 14");
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
nDiscs_ = nDiscs;
// Create the graphic canvas
window_ = new GWindow (new Color (200, 230, 200));
getContentPane().add (window_.getCanvas());
// Create scene
GScene scene = new GScene (window_);
double w0[] = {0.0, 0.0, 0.0};
double w1[] = {4.0, 0.0, 0.0};
double w2[] = {0.0, nDiscs_ * 2, 0.0};
scene.setWorldExtent (w0, w1, w2);
// Add title object and add to scene
scene.add (new Title());
// Create the 3 pegs and add to the scene
int nPegs = 3;
pegs_ = new Peg[nPegs];
for (int i = 0; i < nPegs; i++) {
pegs_[i] = new Peg (i + 1.0);
scene.add (pegs_[i]);
}
// Create the discs and add to the first peg
for (int i = 0; i < nDiscs; i++) {
Disc disc = new Disc ((double) (nDiscs - i) / nDiscs);
disc.setPosition (1.0, i);
pegs_[0].add (disc);
}
pack();
setSize (new Dimension (500, 500));
setVisible (true);
// Create the puzzle and execute the solution
towersOfHanoi_ = new TowersOfHanoi();
towersOfHanoi_.solve();
}
public void discMoved (int source, int destination)
{
// This is the disc to move
Disc disc = (Disc) pegs_[source].getChild (pegs_[source].getNChildren()-1);
double y0 = disc.getY();
double y1 = nDiscs_ + 4.0;
double x0 = pegs_[source].getX();
double x1 = pegs_[destination].getX();
// Animate vertical up movement
double step = 0.2;
double y = y0;
while (y < y1) {
disc.setPosition (x0, y);
disc.redraw();
window_.refresh();
y += step;
}
// Reparent peg
pegs_[source].remove (disc);
pegs_[destination].add (disc);
// Animate horizontal movement
step = 0.05;
double x = x0;
while (x != x1) {
disc.setPosition (x, y);
disc.redraw();
window_.refresh();
x += (x1 > x0 ? step : -step);
if (Math.abs (x - x1) < 0.01) x = x1;
}
// Animate vertical down movement
step = 0.2;
y = y1;
y1 = pegs_[destination].getNChildren() - 1;
while (y > y1) {
if (Math.abs (y - y1) < 0.01) y = y1;
disc.setPosition (x, y);
disc.redraw();
window_.refresh();
y -= step;
}
}
/**
* Graphics object for canvas title.
*/
class Title extends GObject
{
private GSegment anchor_;
public Title()
{
GStyle style = new GStyle();
style.setLineStyle (GStyle.LINESTYLE_INVISIBLE);
style.setForegroundColor (new Color (100, 100, 200));
style.setFont (new Font ("serif", Font.PLAIN, 36));
setStyle (style);
anchor_ = new GSegment();
addSegment (anchor_);
GText text = new GText ("Towers of Hanoi", GPosition.SOUTHEAST);
anchor_.setText (text);
}
public void draw()
{
anchor_.setGeometry (20, 20);
}
}
/**
* Graphics representation of a peg.
*/
class Peg extends GObject
{
private double x_;
private GSegment peg_;
private double[] xy_;
public Peg (double x)
{
x_ = x;
GStyle style = new GStyle();
style.setBackgroundColor (new Color (100, 100, 100));
setStyle (style);
peg_ = new GSegment();
addSegment (peg_);
xy_ = new double[] {x_ - 0.05, 0.0,
x_ - 0.05, nDiscs_ + 2,
x_ + 0.05, nDiscs_ + 2,
x_ + 0.05, 0.0,
x_ - 0.05, 0.0};
}
public double getX()
{
return x_;
}
public void draw()
{
peg_.setGeometryXy (xy_);
}
}
/**
* Graphics representation of a disc.
*/
class Disc extends GObject
{
private double size_;
private GSegment disc_;
private double x_, y_;
public Disc (double size)
{
size_ = size;
GStyle style = new GStyle();
style.setForegroundColor (new Color (255, 0, 0));
style.setBackgroundColor (new Color (255, 150, 150));
setStyle (style);
disc_ = new GSegment();
addSegment (disc_);
}
public void setPosition (double x, double y)
{
x_ = x;
y_ = y;
}
public double getY()
{
return y_;
}
public void draw()
{
double[] xy = new double[] {x_ - size_ / 2.0, y_,
x_ - size_ / 2.0, y_ + 1.0,
x_ + size_ / 2.0, y_ + 1.0,
x_ + size_ / 2.0, y_,
x_ - size_ / 2.0, y_};
disc_.setGeometryXy (xy);
}
}
/**
* Class for solving the "Towers of Hanoi" puzzle.
*/
class TowersOfHanoi
{
public void solve()
{
solve (nDiscs_, 0, 2, 1);
}
private void solve (int nDiscs, int source, int destination, int auxiliary)
{
if (nDiscs == 1)
discMoved (source, destination);
else if (nDiscs > 1) {
solve (nDiscs - 1, source, auxiliary, destination);
discMoved (source, destination);
solve (nDiscs - 1, auxiliary, destination, source);
}
}
}
public static void main (String[] args)
{
int nDiscs = 8;
Demo14 demo = new Demo14 (nDiscs);
}
}
help me please
|
|
|
|
|
it is supposed to be YOUR homework. so I suggest that you do it yourself.
We will help you if you've got a problem, but we do not provide solutions for homework.
|
|
|
|
|
Please wrap your code in Pre tag. it will give better readability to other user to understand your code snippet.
|
|
|
|
|
resize
private BufferedImage resizeImage(BufferedImage originalImage, int type,int width, int hieght){
BufferedImage resizedImage = new BufferedImage(width, hieght, type);
Graphics2D g = resizedImage.createGraphics();
g.drawImage(originalImage, 0, 0, width, hieght, null);
g.dispose();
return resizedImage;
}
convert into gray scale
public static BufferedImage convertToGrayscale(BufferedImage source) {
BufferedImageOp op = new ColorConvertOp(
ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
return op.filter(source, null);
}
public BufferedImage gray(BufferedImage source)
{
BufferedImage image = new BufferedImage(source.getWidth(), source.getHeight(),
BufferedImage.TYPE_BYTE_BINARY);
// BufferedImage.);
Graphics g = image.getGraphics();
g.drawImage(source, 0, 0, null);
g.dispose();
return image;
}
rotate
public static BufferedImage rotate(BufferedImage img, int angle) {
int w = img.getWidth();
int h = img.getHeight();
BufferedImage dimg = dimg = new BufferedImage(h, w, img.getType());
Graphics2D g = dimg.createGraphics();
g.rotate(Math.toRadians(angle), h/2, w/2);
g.drawImage(img, null, 0, 0);
return dimg;
}
horizontalflip
public static BufferedImage horizontalflip(BufferedImage img) {
int w = img.getWidth();
int h = img.getHeight();
BufferedImage dimg = new BufferedImage(w, h, img.getType());
Graphics2D g = dimg.createGraphics();
g.drawImage(img, 0, 0, w, h, w, 0, 0, h, null);
g.dispose();
return dimg;
}
dithering
public static BufferedImage processImage(BufferedImage inputImage) {
// Create a binary image for the results of processing
int w = inputImage.getWidth();
int h = inputImage.getHeight();
BufferedImage outputImage = new BufferedImage(w, h,
BufferedImage.TYPE_BYTE_BINARY);
// Work on a copy of input image because it is modified by diffusion
WritableRaster input = inputImage.copyData(null);
WritableRaster output = outputImage.getRaster();
final int threshold = 180;
float value, error;
for (int y = 0; y < h; ++y)
for (int x = 0; x < w; ++x) {
value = input.getSample(x, y, 0);
// Threshold value and compute error
if (value < threshold) {
output.setSample(x, y, 0, 0);
error = value;
}
else {
output.setSample(x, y, 0, 1);
error = value - 255;
}
// Spread error amongst neighbouring pixels
if((x > 0) && (y > 0) && (x < (w-1)) && (y < (h-1)))
{
value = input.getSample(x+1, y, 0);
input.setSample(x+1, y, 0, clamp(value + 0.4375f * error));
value = input.getSample(x-1, y+1, 0);
input.setSample(x-1, y+1, 0, clamp(value + 0.1875f * error));
value = input.getSample(x, y+1, 0);
input.setSample(x, y+1, 0, clamp(value + 0.3125f * error));
value = input.getSample(x+1, y+1, 0);
input.setSample(x+1, y+1, 0, clamp(value + 0.0625f * error));
}
}
return outputImage;
}
// Forces a value to a 0-255 integer range
public static int clamp(float value) {
return Math.min(Math.max(Math.round(value), 0), 255);
}
public static final int getColorIndexSize(RenderedImage img) {
ColorModel cm = img.getColorModel();
if (cm instanceof IndexColorModel) {
IndexColorModel icm = (IndexColorModel)cm;
return icm.getMapSize();
} else {
return 0;
}
}
|
|
|
|
|
Please don't post messages like this here; read this[^]. If you have an idea for an article then follow these guidelines[^], and do it properly.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Have a TVG in compensation for the little one.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
'm doing my graduation project on RECOGNITION OF HANDWRITTEN SHORTHAND LANGUAGE STROKES .... So, please any one who is interested in it give me some guidelines...
1.thinking to implement it in MATLAB or JAVA... please suggest me which is better ...
2.will i get any module of code to build my project instead of building it from scratch..? if , from where pls specify it....
3.pls any one who is interested in guiding me may pls leave your mail id as comment.. so that i 'll ask for your help...
|
|
|
|
|