JFrames and JDialogs sometimes open behind parent windows but have focus

We are developing a fairly large enterprise Java application with a traditional Swing client.

From time to time we run into the problem that random JDialogs and JFrames open and focus, but hide behind the parent windows.

Unfortunately, this phenomenon is not reproduced and sometimes happens. Until now, it has been recognized on computers that have Win7 and WinXP installed. Since all developers are running Windows operating systems, this does not necessarily mean that this problem is specific to Windows.

I don't know how to fix this problem. Maybe there is a Swing expert who can fix this? (We are still working with Java 6).

+3


source to share


3 answers


JFrames should not have "parents" as they are for the "parent" application window. If you have a window that is intended to be a "child" and therefore needs to be above another window, then it should be a dialog such as a JDialog or JOptionPane and should have a matching parent window.



+4


source


I had the same problem, the error was that the parent JDialog / JFrame was not actually installed correctly. I set it to the parent of the parent which caused the problem.



+2


source


Try adding a FocusListener and listening to the focus received from the event, where you can call yourWindow.toFront (). setAllwaysOnTop () might be of interest to you.

+1


source







All Articles