Disable drag of JFrame

后端 未结 2 780
野性不改
野性不改 2020-12-21 17:26

I want to ask how to make frame can not drag when the application is running?

And then how to disable maximize, minimize button (title bar)?

I\'m using

相关标签:
2条回答
  • 2020-12-21 17:51

    Just add the below line it removes the window decorations like close maximise and minimise(titlebar). This itself disables the dragging only with mouse events.

    frame.setUndecorated(true);
    
    0 讨论(0)
  • 2020-12-21 17:55

    You can use a JWindow instead of a JFrame. There is no title bar, so the user won't be able to move it.

    setResizable(false);
    setUndecorated(true);
    getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
    
    0 讨论(0)
提交回复
热议问题