RT
就是比如1个JFrame上面放了个JPanel,怎样按放大或者缩小一同按比例放大和缩小?
详细点,最好有个简单的例子给我看下...

解决方案 »

  1.   

    使用布局管理器就可以,布局管理器有FlowLayout, GridLayout, CardLayout, BoxLayout, BorderLayout等
    import java.awt.BorderLayout;import javax.swing.JButton;
    import javax.swing.JFrame;
    public class Test extends JFrame {

    private JButton left = new JButton("left");
    private JButton right = new JButton("left");
    private JButton top = new JButton("left");
    private JButton bottom = new JButton("left");
    private JButton center = new JButton("left");

    public Test() {
    this.setTitle("test"); // 标题
    this.setBounds(400, 300, 400, 300);
    this.setLayout(new BorderLayout()); // 设置布局
    this.setDefaultCloseOperation(3); // 关闭退出
    this.add(left, BorderLayout.WEST); // 添加左边的按钮
    this.add(right, BorderLayout.EAST); // 添加右边的按钮
    this.add(top, BorderLayout.NORTH); // 添加上边的按钮
    this.add(bottom, BorderLayout.SOUTH); // 添加下边的按钮
    this.add(center, BorderLayout.CENTER); // 添加中间的按钮
    this.setVisible(true);
    } public static void main(String[] args) {
    new Test();
    }

    }
      

  2.   

    LS正解,如果使用了空布局,则你缩放时无法调整组件大小,空布局一般配合setRisizable(false)一起用