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,179 times
1

dda
- 6,030
- 2
- 25
- 34

Hamza Yerlikaya
- 49,047
- 44
- 147
- 241
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
- 36,252
- 29
- 106
- 169