wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Can anyone explain the function of CellEditor getCellEditorValue() please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Can anyone explain the function of CellEditor getCellEditorValue() please" Watch "Can anyone explain the function of CellEditor getCellEditorValue() please" New topic
Author

Can anyone explain the function of CellEditor getCellEditorValue() please

D R Wilkinson
Ranch Hand

Joined: Oct 29, 2004
Posts: 51
I have read the javadoc on this method but it is a little vague.

Can anyone explain its function in a more definite way.

I am currently adapting the code example at http://www.java2s.com/ExampleCode/Swing-JFC/CheckBoxNodeTreeSample.htmand it is used to return a new CheckBoxNode but I don't understand why or what is calling it?

Thank you.
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
I didn't follow that link to your code,
but suppose the user is editing a cell
of type java.awt.Color that is currently
orange.

After the user changes the value to blue
then your editor's getCellEditorValue()
method should return a java.awt.Color
object that represents blue. The table
(or tree, or whatever custom component)
will call this method to set a new value
for the cell. If it didn't, it would have
no idea how the user changed the cell's value.


bitguru blog
D R Wilkinson
Ranch Hand

Joined: Oct 29, 2004
Posts: 51
Thank you for the explanation.
D R Wilkinson
Ranch Hand

Joined: Oct 29, 2004
Posts: 51
Okay...

My renderer is made up of a JPanel with a JCheckBox (west) and a JLabel (center). My editor is the same.

Each tree node ( renderer or editor ) represents one of three 'components' of a book - The book itself containing, chapters, which in turn contain, scenes.

I have an abstract BookComponent class which implements getters and setters for two private fields 'isSelected' and 'componentTitle'. The 'isSelected' field has nothing to do with the selected state of any tree node. It indicates whether the user has selected the book, chapter or scene for exporting, printing, etc.

The three specialised subclasses: Book, Chapter and Scene all extend BookComponent and provide specialised fields and methods.

My renderer needs to display the 'isSelected' state ( using the JCheckBox ) and the 'componentTitle' using the JLabel.

My editor needs to allow the user to edit the 'isSelected' state ( using the JCheckBox ) and the 'componentTitle' using the JLabel of the BookComponent subclass object the tree node represents.

I thought that a tree node renderer queries the user object of the tree node that is currently being rendered, for the values it needs to display and renders them in place.

When a tree node is edited, its display is taken over by a tree node editor.

This editor queries the user object of the tree node that is currently being edited, for the values it needs to display - ie the user objects current state before any editing takes place.

Then it needs to accept any user changes ( checking or unchecking the checkbox, entering text in the label ) and pass these changes on to the user object the tree node is representing.

When a different tree node is clicked on, the tree node that was previously being displayed by an editor is now being displayed by a renderer. As the renderer gets the values to display from the tree nodes user object, the tree nodes should display their new state.

Mine doesn't - when I check a book components tree node check box ( when in editor mode ) this nodes JCheckBox fails to retain its checked state ( when in render mode ). I haven't tackled the JLabel yet.

If I have understood your example properly, the tree node is representing a Color object. When the user changes the colour using an editor, this editor returns a new Color object that represents the new colour.

Mine represents two properties of a specific BookComponent subclass - I cannot have the edited tree node renderer display a new BookComponent subclass object - it needs to display the values of the BookComponent subclass it represents... not a new one.

I am trying to get there but at the moment, in my usage, I am still unclear what this method is supposed to return?
[ March 03, 2006: Message edited by: D R Wilkinson ]
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

Hi Wilkinson

I'm also having same issue as similar to your problem. can you please help me how to fix this.


-Chiru
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Not likely. Mr/Ms Wilkinson has not posted anything for over 3.5 years now, so he/she is probably no longer visiting us.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

Thats sad Rob

i was searching on this error, i got this post. we will see.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can anyone explain the function of CellEditor getCellEditorValue() please