This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to keep a table cell "activated"/focused while validating its content in the table model?  RSS feed

 
Ralf Wahner
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear ranch people

I use the tableChanged() method from the TableModelListener interface to check if an 8-digit customer id has been typed in the corresponding table cell:

After the setValue() method has been processed, the JTable keeps the selected row, but forgets the previously selected cell. I would like to keep the cell "activated" (not sure if "focused" is the right term), so that the user can immediately rectify the wrong input. How can the table model communicate this information to the JTable in a way satisfying the rules of OO?
 
Mithil Wane
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You might want to have a look at this example. Its a little big for something small like what we need but nevertheless have a look.

http://download.oracle.com/javase/tutorial/uiswing/components/table.html

Go to "Using an Editor to Validate User-Entered Text "

 
Campbell Ritchie
Sheriff
Posts: 55292
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Mithilwaine" you appear to be ignoring our warnings about the naming policy. This is not optional. Change your displayed name to match the policy now.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!