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

后端 未结 6 1390
孤城傲影
孤城傲影 2021-01-18 07:47

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

相关标签:
6条回答
  • 2021-01-18 08:25

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

    0 讨论(0)
  • 2021-01-18 08:35

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

    0 讨论(0)
  • 2021-01-18 08:42

    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.

    0 讨论(0)
  • 2021-01-18 08:45

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

    0 讨论(0)
  • 2021-01-18 08:47

    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.

    0 讨论(0)
  • 2021-01-18 08:48
    setVisible(true);
    

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

    0 讨论(0)
提交回复
热议问题