Disable drag of JFrame

后端 未结 2 787
野性不改
野性不改 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: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);
    

提交回复
热议问题