• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Focus problem

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!
That solved my problem.
And to your question, yes, I explicitly called requestFocus() in my code.
 
My first bit of advice is that if you are going to be a mime, you shouldn't talk. Even the tiny ad is nodding:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic