wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JTree Node with Text plus JComboBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree Node with Text plus JComboBox" Watch "JTree Node with Text plus JComboBox" New topic
Author

JTree Node with Text plus JComboBox

Danny Farmer
Greenhorn

Joined: Jul 15, 2010
Posts: 2
Hi,
I have got a JTree, that should look as follows:
Root is always there and shall just be a String "Layouts" and not editable. (This makes no problems)
By right-clicking on the root comes a menu where I can choose "new layout". So far so good.
A layout shall have a selfchosen name, which shall be chosen directly after clicking "new layout". That worked with

but then I got the order, that the cell shall also have a JComboBox constantly showing, which type of Layout is selected, So the cell has to be like this: <selfchosen LayoutName e.g. "DataFrom15-07-2010"> <JComboBox WithActualTypeShowing>.
I tried something with a selfwritten LayoutTreeCellEditor that extends DefaultCellEditor.
But meanwhile I am just left confused with all the interaction of renderers, editors, values and defaultstuff, that I would be very, very pleased if there is (/are) someone, that can explain to me the cooperation of CellEditors, DefaultCellEditors, DefaultTreeCellEditors, CellRenderers, DefaultTreeCellRenderers and especially the methods of them: getTreeCellRendererComponent (I guess this gives back the JLabel, which is normally "the JTree-cell", but I want to have a JComboBox with a JLabel as "layoutName"), getTreeCellEditorComponent (I guess this is a Component with that I can edit the cell. But I want the JComboBox to be constantly shown as part of the cell), getCellEditorValue (in the meantime I thought I could just give back a JPanel with the JLabel and JComboBox on it. But it didn't work.) and where they all get called.
I am confused. :-( Can someone light this up?
Thank you very very much!!!
Regards,
StudentAssistent
Kamal Wickramanayake
Greenhorn

Joined: Jul 10, 2010
Posts: 27
But meanwhile I am just left confused with all the interaction of renderers, editors, values and defaultstuff, that I would be very, very pleased if there is (/are) someone, that can explain to me the cooperation of CellEditors, DefaultCellEditors, DefaultTreeCellEditors, CellRenderers, DefaultTreeCellRenderers and


Look at The Java Tutorial. These are nicely explained there.
Danny Farmer
Greenhorn

Joined: Jul 15, 2010
Posts: 2
Kamal Wickramanayake wrote:Look at The Java Tutorial. These are nicely explained there.

You could use this answer in nearly every post in this and other Java-forums. But it helps not me nor others. At least I could understand as good as everything if I had no time pressure and endless time. Of course I looked up in the internet and searched something about it. And found something, read some of the things and tried it out. But I didn't get the whole issue. So I thought, because it is a relatively "small" thing, someone could give me a special advice about it.
Or maybe at least a link. There are thousands of Java-tutorials in the internet. if you mean this one: http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/uiswing/components/tree.html , then I have done this already. But there is not explained how I can handle 2 UserObjects for 1 Cell that shall both be editable individually , the name as text plus the other value as chosen value from the ComboBox. This is, where I had no idea.
Kamal Wickramanayake
Greenhorn

Joined: Jul 10, 2010
Posts: 27
But it helps not me nor others.


I don't agree. What I gave is a very specific answer for the issue you are having. And it was for a specific part of your problem identified by the quoted text. When someone answers a question with 'yes', it doesn't mean that 'yes' is a generic answer and not acceptable for the question asked just because 'yes' can be used to answer an infinite number of different questions.

May others assist you.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JTree Node with Text plus JComboBox
 
Similar Threads
JTree not updating
Select a node in Jtree
JTree TreeNode question
How to add child node on right click of a node to a JTree
JTree - collapsePath issue