How can i set a jFrame to be always on top and focuse enabled until it is closed?

前端 未结 1 1592
星月不相逢
星月不相逢 2020-12-11 03:01

There are two different Frames in my program and the second one open when i click the jButton is the first frame,so when the second frame is opened, I want the second frame

1条回答
  •  不知归路
    2020-12-11 03:41

    JFrame frame = new JFrame ();
    frame.setAlwaysOnTop (true);
    

    If you want frame to be always focused, you probably need to use modal dialog instead of JFrame:

    JDialog dialog = new JDialog ();
    dialog.setModal (true);
    dialog.setAlwaysOnTop (true);
    dialog.setModalityType (ModalityType.APPLICATION_MODAL);
    

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