I have done as follows. But I am getting ClassCastException in the return statement.Even I tried with JTextField also. I am getting the same exception
In the NonRootEditor class I have written as follows:
When I click on the Parent and child nodes I am able to edit the node with MyTextField. I want Parent nodes to be of legth 15 where as the child nodes to be of length 20. How can I achieve this?
With the following code, I am getting both Parent and Child nodes to be of size 20. But I want different sizes. Please help me out!!!
Does anyone have idea on how to make some specific nodes in JTree as non editable.
My tree structure is as follows:
Root 1

Parent 1

Child 1
......
Child n
.....

Parent n
Root 2
Root 3
......
Root n
where I want the nodes Root 1, Root2....Root n to be non editable.
But the Parent nodes and child nodes to be editable.
The tree has popup which has options for renaming these nodes.
So I have set as follows
tree.setEditable(true);
How to make nodes Root 1, Root2....Root n to be non editable?
Where I get popup on right click of the node with options Add, Remove & Rename. So I can rename the node. The node name’s length should be <=16 characters. So while renaming the node, I want to stop the keystrokes if it reach 16 characters.
The tree is featured with a popup which appears while right clicking on the node which gives options for adding a node, removing a node and renaming a node.
So whenever a node is added or removed or renamed I want to display the nodes in a sorted order. I want to sort the nodes alphabetically at branch level.
ie. Parent nodes level and child nodes level.
It would be very helpful if you provide me with some good way to do this.
Thanks in advance
I have written the follwing code and garbage collection is happening properly and memory leakage problem is almost solved.
panel.removelAll(); //(panel is nothing but a JPanel) which removes all the components from the container and dispatches all the events also
panel = null; //After removing all from the panel and making it null ensures the panel to be garbage collected.
William Brogden wrote:
Does your GUI involve any event listeners?
Improperly disposed of listeners are a prime cause of memory leaks with GUI apps.
Bill
We are facing memory leak problem while running our application. We are using JProfiler to identify the rerason and found the follwing:
1) While making Outer class objects as null it is not getting garbage collected. Since inner classes are referring to Outer class.
How to make the objects garbage collected in this case?
2) We have a lot of Swing Components. They are also not gettiing garbage collected. What could be the possible reasons?
Your response will be very helpful
Thanks in advance.
While calculating logarithm values in JDK1.4 it returns some unpredicted values. As Math.log() returns double so there is loss of precision and exact log base 10 values cannot be calculated.
For a CR in TP, a formula was given as:
DispCode = Int ( 1 * log10( abs(LsbRsln)))
which is written in Java as,
int dispcode = (int) (1 * (Math.log(Math.abs(Double.parseDouble(lsbrsln))) / Math.log(10)));
For example, if lsbrsln = 0.001, the formula is expected to return 3, instead it returns 2. The following part of the formula
Math.log (Math.abs (Double.parseDouble(0.001))) / Math.log(10) is returning 2.999999� and finally the formula is returning 2 while casting it into int.
In JDK1.5 we have Math.log10 method itself for calculating logbase10 values. But since we need to support JDK1.4 also we were not able to use that also.
While calculating logarithm values in JDK1.4 it returns some unpredicted values. As Math.log() returns double so there is loss of precision and exact log base 10 values cannot be calculated.
For a CR in TP, a formula was given as:
DispCode = Int ( 1 * log10( abs(LsbRsln)))
which is written in Java as,
int dispcode = (int) (1 * (Math.log(Math.abs(Double.parseDouble(lsbrsln))) / Math.log(10)));
For example, if lsbrsln = 0.001, the formula is expected to return 3, instead it returns 2. The following part of the formula
Math.log (Math.abs (Double.parseDouble(0.001))) / Math.log(10) is returning 2.999999� and finally the formula is returning 2 while casting it into int.
In JDK1.5 we have Math.log10 method itself for calculating logbase10 values. But since we need to support JDK1.4 also we were not able to use that also.