JFrames and JDialogs sometimes open up behind their parent windows but have focus

前端 未结 3 1775
遇见更好的自我
遇见更好的自我 2021-01-19 03:45

We are developing a rather big Java enterprise application with a traditional Swing client.

Every now and then, we facing the problem that random JDialogs and JFra

相关标签:
3条回答
  • 2021-01-19 04:08

    JFrames should not have "parents" as they are meant to be the "parent-most" window of an application. If you have a window that is meant to be a "child" and is therefore meant to be above another window, then it should be a dialog such as a JDialog or JOptionPane and should have its parent window set accordingly.

    0 讨论(0)
  • 2021-01-19 04:17

    Try to add a FocusListener and listen for focus gained event where you can call yourWindow.toFront(). setAllwaysOnTop() could be interesting for you too.

    0 讨论(0)
  • 2021-01-19 04:18

    I once had the same problem: The error was that the JDialog's/JFrame's parent was in fact not set properly. I set it to the parent of the parent, which caused the issue.

    0 讨论(0)
提交回复
热议问题