set size wont work in java

后端 未结 3 612
闹比i
闹比i 2021-01-05 04:38
public void start_Gui() {

    JFrame window = new JFrame(\"Client Program\");
    window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JP         


        
3条回答
  •  甜味超标
    2021-01-05 05:03

    In Swing, you have two options for layout: do everything manually or let a LayoutManager handle it for you.

    Calling setSize() will only work when you're not using a LayoutManager. Since you're using a GridLayout you'll have to use other ways to specify what you want.

    Try calling setPreferredSize() and setMinimumSize().

提交回复
热议问题