IntelliJ Java IDE
The moose likes Swing / AWT / SWT / JFace and the fly likes Keeping my custom Icon visible while editing and another question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "Keeping my custom Icon visible while editing and another question" Watch "Keeping my custom Icon visible while editing and another question" New topic
Author

Keeping my custom Icon visible while editing and another question

kiril simeonov
Greenhorn

Joined: Dec 19, 2001
Posts: 4
Hi group, I have two questions which made my life pretty unpleasant.
1. I try to edit tree nodes which contain custom Icons but at the moment as I start editing them my these vanish (Java replace them with default ones)and when I am ready with the editing they are displayed again.
I suppose I have to define my own CellEditor which extends DefaultTreeCellEditor but what I have exactly to do ???
2.The second question also concerns the editing.My problem is not managing to edit a cell again after a non valid entry has been made.The situation looks like this:
/**Adding the node to the tree*/
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode("");
DefaultTreeModel model = (DefaultTreeModel)tree.getModel();
model.insertNodeInto(newNode, selectedNode,
selectedNode.getChildCount());
/**Starting editing at Path*/
TreePath treePath = new TreePath(model.getPathToRoot(newNode));
tree.startEditingAtPath(treePath);
So far so good...
Then I take the value of the editor with
String newName =(String)tree.getCellEditor().getCellEditorValue();
and then I say for example
if(newName.equals("")){
tree.startEditingAtPath(treePath)
}
With other words if the entry is empty start editing again but I didn't work.
If anyone can help me understand my problem better than please do make your contributions. I would appreciate that much.
I thank you all in advance
 
 
subject: Keeping my custom Icon visible while editing and another question
 
Threads others viewed
showing a text file from a jtree selection path
Jtree - message becomes blurry when scrolls
how do I get the current node selection in a Jtree?
how to fill the jtree with the last modified value ?
JTree help
MyEclipse, The Clear Choice