This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue with JTables and saving on screen content to underlying TableModel  RSS feed

 
Tommy Greenberg
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a situation where I have a JTable. Along with the JTable there is a button in the JPanel that brings up the next view.

I am using the default editor and renderer.

My issue is when I am editing a cell, I click the button to go to the next view without hitting enter and I am not having the cell in the editting state update.

The onscreen String does not get stored in the TableModel, and even though I click off the table, by clicking on the button, focus is never shifted out of that cell. Focus seems as if it should move, because the action of the button is performed.

The result is the TableModel never updates and the information I needed to store from that last cell is lost when I move to the next view.

How do I fix this? This is a requirement, that the user is able to click the next button while the cell is still being editted and the onscreen information of that editted cell should be stored in the TableModel without the user having to manual change cell focus, or hit the enter key before clicking the next button.

I've tried everything from a Pub-Sub on the TableModel to an ActionListener. The only thing I haven't tried is customizing the cell editor.
[ August 22, 2006: Message edited by: Tommy Greenberg ]
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The next button works like the tab key now.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!