File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can anyone explain the function of CellEditor getCellEditorValue() please

 
D R Wilkinson
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 886
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
D R Wilkinson
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the explanation.
 
D R Wilkinson
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 290
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Wilkinson

I'm also having same issue as similar to your problem. can you please help me how to fix this.
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not likely. Mr/Ms Wilkinson has not posted anything for over 3.5 years now, so he/she is probably no longer visiting us.
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats sad Rob

i was searching on this error, i got this post. we will see.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic