This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

window focus

 
Deyna Cegielski
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there a method to bring a window that is in the background to the front?
 
Tal Nathan Tal Nathan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look in the api but there is a way to set a window to be always on top I think you use setAlwaysOnTop(true); in your JFrame.

Would show(); not bring it to the front as well?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, show() won't bring it to the front. You oughtn't to use show() at all, but setVisible(true).

I think you were correct in your first suggestion; there is a method in the API; it is called toFront(). There are several like that, toFront(), toBack(), and setAlwaysOnTop(boolean), which will have your Window on top all the time, which is probably not what you want.

While you're in the API, have a look at the related java.awt.Component.requestFocus() methods.

CR
[ April 19, 2006: Message edited by: Campbell Ritchie ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic