Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Missing last edit on a JTable  RSS feed

 
Alejandro Barrero
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I enter data in a cell and move the cursor to click on "Ok", the last data entered is not received by the table. To handle this problem, I added a mouse motion listener to the table with the following code:

My problem is that this code works some times and some times doesn't work. The code is not throwing exceptions.

Your help would be greatly appreaciated,

Alejandro Barrero
 
Alejandro Barrero
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the solution. I noticed that when I was breaking in the debugger it was working. All that is needed is to sleep for 200 msecs (this may be system dependent); I used:

This problem is a flaw in Swing that pesters many people, I noticed similar posts without answers. I wish there was a way to make the solution well known.
 
Brian Cole
Author
Ranch Hand
Posts: 935
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Alejandro Barrero:
When I enter data in a cell and move the cursor to click on "Ok", the last data entered is not received by the table.


The easiest way to fix this is:

jForeignKeysTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

Sun has handled this bug poorly. See bug#4709394 for more details.
[ April 07, 2008: Message edited by: Brian Cole ]
 
Alejandro Barrero
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Brian; that works like a charm.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!