Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

stopCellEditing() not called at all?

 
Andreas Johansson
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to override the stopCellEditing() method in DefaultTreeCellEditor to prevent the user from entering an empty string as the name for the node in the tree.
My problem is that it seems that stopCellEditing() is never called when Return is pressed. But cancelCellEditing() is called when Escape is pressed. Strange... What am I doing wrong?
I've read this, is it correct:
boolean stopCellEditing(): used to stop a current cell edit. This method can be overriden to perform input validation. If a value is found to be unacceptable we can return false indicating to the component that editing should not be stopped.

 
Andreas Johansson
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again!
I found the cause of my problem, apparently it was a nasty bug in Swing!!
Bug Id: 4436145
Synopsis: JTree does not correctly handle stopping of editing.

If you build a custom TreeCellEditor for a JTree, and do NOT want editing to stop when you select another cell, this is currently unsupported. In fact, if you open a cell for editing and return false from stopCellEditing in order to signal invalidate editing data, the editor is STILL closed leaving invalid data inside it.

Read more at (if you have a developer account at sun): http://developer.java.sun.com/developer/bugParade/bugs/4436145.html
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see on the bug database that this is fixed. I'm using 1.5 and for the life of me I can't get the code in stopCellEditing() to be called either. Did something significant change or is this bug still around?

Cheers,
Rachel
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BasicTreeUI will do nothing in the mouse listener if the editor returns false from stopCellEditing. If you wish to completely disable functionality you will have to override the expand/collapse methods, disallow changes to selection, as well as not allowing the tree to lose focus.
xxxxx@xxxxx 2001-04-16


You're going to have to take a different approach. It's fixed in the sense that it does what they want it to and isn't a bug anymore, but it still doesn't behave the way you think it should. At least that's my interpretation.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!