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

how would i keep client in textfield of jtable once error thrown

 
john mattucci
Ranch Hand
Posts: 331
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have extended DefaultTableCellRenderer so that when a particular field in a column which is part of a JTable is filled with an invalid entry it turns red. I want this to happen so that the user is aware of their error. My next step which I want to do is to keep the user in that field. What would be the easiest way to go about keeping them in that field, without being able to enter into other fields??
Thanks for your time
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Attach a FocusListener to the field that calls the validation code. If the validation passes, do nothing. If the validation fails, change the background color, and call requestFocus() on the field.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if the user needs to look the information up somewhere else? They move the mouse to go check and you take them right back. Is this a user requirement?
 
john mattucci
Ranch Hand
Posts: 331
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no need for them to move back. In the JTable i will have 2 columns one will contain a start date and the 2nd an end date. So im simply checking if the dates entered are correct
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic