wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes LostFocus and SwingUtilities.invokeLater() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "LostFocus and SwingUtilities.invokeLater()" Watch "LostFocus and SwingUtilities.invokeLater()" New topic
Author

LostFocus and SwingUtilities.invokeLater()

dharmesh baveja
Greenhorn

Joined: Dec 18, 2000
Posts: 13
Hi,
I am facing proble , which is as below:
1.I have got a JtextField on which i am doing validation on lostfocus()
2.But when one clicks the some button on Frame and focus was on the JTextField , two things happen:
a)Lost Focus happens on JtextField.
b)Jbutton_action_perfomed happens.
3. I want on such a click on button , the validation to be skipped out.
4. I think i can handle this case by invokelater() , but how?
5.Desired is:
1. On lostfocus , validation() will be excuted and returning focus back to JTextFiled.
2.On button click , i want to skip the execution of validation() by setting flag & skipping the run method of thread in invokelater(). This can be done in button_actionprformed().
Please send me the rough outline code for:
1.invokelater
2.processing to be done in button_actionperformed().
Pls help me urgently!!
Thanks in advance.
Dharmesh
Laurent Leonard
Ranch Hand

Joined: May 15, 2001
Posts: 35
If youare using Java 1.3 or later, you can use the class InputVerifier.
myTextField.setInputVerifier(aVerifier);
And if you want to avoid the check (for example with a cancel button), you can see the method setVerifyInputWhenFocusTarget.

You can look also to the class PlainDocument if you want some
"clever" behaviour for your widget.

------------------
Laurent Leonard
Laurent.Leonard@belgique.com


Laurent LEONARD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: LostFocus and SwingUtilities.invokeLater()
 
Similar Threads
Focus traversal issue
catching TAB in key event
struts validator
question on changing focus
FocusLost help needed