I am in a situation where I create a frame FrameB from my main frame FrameA. When the user is working on FrameB I would like it to be on top of FrameA even when the user accidentally clicks on FrameA.
Asked
Active
Viewed 3,106 times
1
dda
- 5,760
- 2
- 24
- 34
Hamza Yerlikaya
- 48,407
- 41
- 141
- 236
2 Answers
4
Do you have to use a JFrame?
If you use a JDialog instead of a JFrame and assign FrameA as the owner of the dialog through the constructor it will always remain on top of the frame. (Example: How to set the JFrame as a parent to the JDialog)
Otherwise you can use setAlwaysOnTop() from the window class, but this can be dependent on the operating system/window manager.
3
You could consider making FrameB a JDialog instead of JFrame, and set it modal.
Joonas Pulakka
- 35,643
- 27
- 105
- 168