This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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!!!
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.
Joined: Jul 15, 2010
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.
Joined: Jul 10, 2010
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.