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.
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 ]