Solved

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

Posted on 2013-11-01
1
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 36

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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 “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

689 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