• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting JFrame on top of other frames

 
Velika Srbija
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to set a particular frame of my swing app to be always visible, i.e. to be always on the top of all other frames in my app. How should I set it up?
Note: Frame shouldn't be modal.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is really only one way to do this without setting the JFrame modal and without JNI...
Create a WindowListener that anytime the JFrame loses focus or gets put behind another window, the toFront() method is called.
This is sloppy though because you will see it go behind then come back to the front. But like I said, no other way....(About 99% sure on this anyway)
 
Velika Srbija
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
Gonna try it.
Hope it will not flicker to much.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!