禁用 JFrame 的拖动

2022-01-24 00:00:00 java swing jframe drag

请问如何让应用程序运行时框架不能拖动?

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)?

我正在使用 JFrame.

推荐答案

只需添加以下行,它会删除关闭最大化和最小化(标题栏)等窗口装饰.这本身仅通过鼠标事件禁用拖动.

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);

相关文章