I am developing desktop Java application using NetBeans JBuilder. I make the contents of the program (front page) to fit in a relatively small window. I am using GridBagLayout. Once I run the program and zoom it in with the button on the right top hand side of the window the program takes all the screen of my laptop. But the contents looks like a mess. I want to deny zoom in once it is pressed i.e. I want my program to stay in the same size no matter whether you zoom it in or not. How to do that?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The program by default does not extend JFrame or JDialog. It is using Swing Application Framework library which is made part of project. It extends FrameView class.
You should really try RTM. I don't use this abandoned API, yet it took just a few seconds to discover... FrameView.getFrame()
.
Then of course, you can use Jeffrey's advice of Frame.setResizable(boolean)
.
回答2:
Frame#setResizable(false);
Dialog#setResizable(false);
回答3:
you should use Frame.setResizable(false)
and set the size of frame to maximize size
Dimension d=getMaximumSize();
Frame.setSize(d.width, d.height);