jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes Focus problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Focus problem" Watch "Focus problem" New topic

Focus problem

tormod eriksen
Ranch Hand

Joined: Jan 23, 2002
Posts: 52
Focus seems to lock.
It happens when in the actionlistener code for a JButton JOptionPane.showMessageDialog(...) is called twice before a JComponent.requestFocus() is called.
Now focus seems to lock on the JButton that is pressed. This JButton has visual focus, but not real focus, and focus can't reach the JButton by tabbing.
The JComponent that called requestFocus() has visual and keyboard (real) focus.
If JOptionPane.showMessageDialog(...) is called once before JCompoent.requestFocus focus visually leaves the JButton, the JComponent that called requestFocus() has focus. So there's no problem.
I use the last version of 1.3
If I run the application under 1.4 the problem has vanished.
But I want to run the application under 1.3, at least for some more time.
Has anyone stumbled into this sort of problem before? Any ideas how to come around the problem?
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
I'm not completely clear on your post, but I just have a question.
Are you explicitly calling .requestFocus() in your code? I know there is some level of complexity and confusion with requestFocus(). I read an article about it JavaWorld article. Not sure if this applies to you, but it can't hurt.

Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
tormod eriksen
Ranch Hand

Joined: Jan 23, 2002
Posts: 52
That solved my problem.
And to your question, yes, I explicitly called requestFocus() in my code.
I agree. Here's the link: http://aspose.com/file-tools
subject: Focus problem
It's not a secret anymore!