This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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?
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"
Joined: Jan 23, 2002
Thanks! That solved my problem. And to your question, yes, I explicitly called requestFocus() in my code.