Solved

Node text changes when I edit it - how to stop this?

Posted on 2013-11-01
1
213 Views
Last Modified: 2013-11-17
I create a treenode as follows...

DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("mytext,GroupIcon");

Open in new window


Then I use a custom renderer to parse the data to determine what icon to use...
case "GroupIcon":
				this.setIcon(new ImageIcon(frmMyForm.class.getResource("/proj6/java/group.png")));
				setText(x[0]);
				break;

Open in new window



The node shows text "mytext" as it should and the icon is correct.  The only problem is when you edit the node (by double-clicking on it), the text changes to the full value of "mytext,GroupIcon".  How can I fix this?

Simply changing the icon using another method is not the answer I'm looking for because of other factors.

I tried creating custom node with custom properties like this...

n1.setStrIconType = "Group";

Open in new window


but I couldn't seem to access the custom properties within the custom renderer.

Any help would be appreciated.
0
Comment
Question by:pdering
1 Comment
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 39618216
If you want to do it that way you would have to provide similar logic as in the Renderer, in a custom TreeCellEditor aswell. With what you have posted, that's about as much as I can say. If you need more help than that, can you post your full code?

Also, I think the way that you were going with using a custom TreeNode class is probably the best. If you can post what you did there, we can probably help overcome the difficulty that you had accessing the custom properties.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
eclipse shortcuts 9 63
tomcat startup error 5 102
jsp login check 12 42
How  can  i  resolve  HTTP Status 404 -? 8 43
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question