I have to resize my JFrame for the contents to show up. How can i fix that?

天涯浪子 提交于 2019-12-01 16:30:02

问题


When I run my gui, I have to resize the window for everything to show up. Does someone know what the problem is?


回答1:


Call pack() on your JFrame, after adding all your components and before calling setVisible(true).




回答2:


When you create the frame call the setSize() method on the frame to set the initial starting size.




回答3:


setVisible(true);

after you have added all desired JComponents to your JFrame helped for me.




回答4:


don't need to add pack() method.

Just add the setSize(int, int) on the end of everything, then it will work well.

and setVisible(true) on next to setSize.




回答5:


I was also having the same problem.

After making any change on the JFrame view, just recall the setVisible(true) method. It just worked for me.




回答6:


The setBounds() method will resize and reposition a Window. however you might want to look at the way your components are laid out if pack() isn't working (I believe it relies on minimum/preferred sizes of components).



来源:https://stackoverflow.com/questions/5498821/i-have-to-resize-my-jframe-for-the-contents-to-show-up-how-can-i-fix-that

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