JFrame: How to disable window resizing?

橙三吉。 提交于 2019-11-30 02:44:38

You can use a simple call in the constructor under "frame initialization":

setResizable(false);

After this call, the window will not be resizable.

Use setResizable on your JFrame

yourFrame.setResizable(false);

But extending JFrame is generally a bad idea.

Ipsit Gaur

Simply write one line in the constructor:

setResizable(false);

This will make it impossible to resize the frame.

This Code May be Help you : [ Both maximizing and preventing resizing on a JFrame ]

frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setVisible(true);
frame.setResizable(false);

Just in case somebody didn't understand the 6th time around:

setResizable(false);

it's east use:

  frame.setResizable(false);

You can use this.setResizable(false); or frameObject.setResizable(false);

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!