• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Focus problem

 
tormod eriksen
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
tormod eriksen
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
That solved my problem.
And to your question, yes, I explicitly called requestFocus() in my code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic