Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-11-01
1
Medium Priority
?
217 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

636 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