File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Java swing issue from 1.4 to 1.6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Java swing issue from 1.4 to 1.6" Watch "Java swing issue from 1.4 to 1.6" New topic

Java swing issue from 1.4 to 1.6

Pravin Sutrave

Joined: Sep 17, 2012
Posts: 1
Dear friends,

We are migrating from java 1.4 to 1.6 with frontend being Java Swing. Now the focus is giving us a very hard time.
The main issue is when we tab out of a textfield, focuslost method is called in which we validate the content of the textfield. If the content is correct we return true and the focus moves ahead to the next textfield. If the content is invalid we show a popup validation message in JDialog, call the same textfield.requestFocus() and return false. Now on calling this textfield.requestFocus() again before returning false the focuslost is again triggered on the textfield and the validation message is displayed again in the popup. This happens only twice, everywhere we show a validation message in a popup and request the focus back on the field.
Please help us.
Darryl Burke

Joined: May 03, 2008
Posts: 5115

Does your code respect Swing's single threaded rule? If not, fix that first.

See the documentation for requestFocusInWindow():
... developers are strongly encouraged to use this method over requestFocus when possible.

Additionally, you may need to wrap the request in invokeLater(...).

luck, db
There are no new questions, but there may be new answers.
I agree. Here's the link:
subject: Java swing issue from 1.4 to 1.6
It's not a secret anymore!