Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getting the focus back  RSS feed

 
satya sahu
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a text field. I am doing some validation for that text field. If the user enters some invalid value and then presses tab, then appropriate message should be displayed. I am able to do this. I want to focus back on the same text field. How to do this ??
Thanks in advance.
 
sasi kala
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi satya,

I want to focus back on the same text field. How to do this ??


use jTextField1.requestFocus(); after displaying the message.

example,
JOptionPane.showMessageDialog(this,"Please Enter valid data");
jTextField1.requestFocus();

If the validation has to done for several fields use method like

Hope This Helps
All The Best
[ March 28, 2005: Message edited by: sasi kala ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!