• Post Reply Bookmark Topic Watch Topic
  • New Topic

Focus gaining  RSS feed

 
Patrick Brahami
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to gain focus on a JPanel of mine, and it doesn't work.
The panel is set to focusable(true).

I have a JDialog that is opened from the main JFrame. Now on the dialog I got a confirm button, that by clicking it (among other stuff) it does
panelname.getfocusinwindow();

but focus isn't gained, why so?
the confirm button also disposes of the JDialog if it matters.

Thanks in advance.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's hard to say what's wrong without code. Your best bet here may be to show us your code. We don't want to see all of it, but rather you should condense your code into the smallest bit that still compiles, has no extra code that's not relevant to your problem, but still demonstrates your problem, in other words, an SSCCE (Short, Self Contained, Correct (Compilable), Example). For more info on SSCCEs please look here: SSCCE
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try putting the request focus call on a separate thread using SwingUtilities.invokeLater
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!