Solved

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

Posted on 2013-11-01
1
211 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
for i loop in grovy 1 44
Eclipse IDE - Cannot copy/paste from console output 8 126
mockito example issue 8 62
javap not working 8 36
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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now