怎样在程序运行中改变JFrame的大小
我试过setSize和resize,但这两个函数都把窗口截了一部分下来显示,连边框都没了,因该怎么做呢?

解决方案 »

  1.   

    frame.setSize(xxx, xxx);
    frame.validate();
      

  2.   

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;public class TrySize extends JFrame implements ActionListener
    {
    JButton button;
    public TrySize()
    {
    super();
    button = new JButton("press");
    button.addActionListener(this);
    this.getContentPane().add(button);
    this.setBounds(0,0,300,300);

    this.setVisible(true);
    }
    public static void main(String arg[])
    {
    new TrySize();
    }
    public void actionPerformed(ActionEvent e)
    {
    this.setBounds(0,0,600,600);
    this.setVisible(true);

    }
      

  3.   

    JFame jf = new JFame;
    jf.setSize(长, 高);
    jf.show();