frame1.setSize(300,400);//设置窗体大小
frame1.isResizable(false);//窗体大小不可改变

解决方案 »

  1.   


    frame1.setResizable(false);//窗体大小不可改变
    frame1.setResizable(true);//窗体大小可改变
      

  2.   

    在frame1.setVisible(true);下面添加以下2句,其中setSize(int width,int height)
    例如:
    frame1.setSize(100,200);
    frame1.setResizable(false);
      

  3.   

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;public class GBApp
    {
    public GBApp(){}; public static void main(String[] args)
    {
    JFrame frame1 = new JFrame("First App!");
                      JButton but1 = new JButton("Hello, World!");  
    frame1.pack();
                       //IntWidth,IntHeight 为初始化的大小值。
                       frame1.setSize(IntWidth,IntHeight);
                       frame1.setResizable(false);
    frame1.setVisible(true);
    WindowAdapter winAdapter = new WindowAdapter()
    {
          public void windowClosing(WindowEvent e) {System.exit(0);}
    };
    frame1.addWindowListener(winAdapter);
              }
    }
      

  4.   

    另外还的加 :
      frame.getContentPane().setLayout(new FlowLayout( ));
      frame1.getContentPane().add(But1); new FlowLayout( ) 处可以换成你所需要的,才能正常显示GUI内容。
      

  5.   

    加两句
    frame1.setSize(300,400);
    frame1.isResizable(false);
      

  6.   

    o 学学,看看
    WindowAdapter winAdapter = new WindowAdapter()
    {
          public void windowClosing(WindowEvent e) {System.exit(0);}
    };是什么意思《-----仁者见仁,智者见智------》