请问:
如何实现窗口中的组件大小随其窗口尺寸的调整而改变?例如:我在JInternalFrame或JFrame中加入了多个JLabel,JButton,...等多个组件, 当用户调整窗口时,这些组件能够自动实时改变其位置大小(包括字体大小),比如原来我默认布局好的内容是刚好充满整个窗口,当我用鼠标调整窗口大小时,窗口中的组件(内容)也能按比例调整。在此先谢谢各位了!!!

解决方案 »

  1.   

    使用边界布局啊,BorderLayout
    ding!!!
      

  2.   

    这很简单,用好布局管理器就可以了.
    你运行一下下面的程序,看看是不是你想要的效果....import java.awt.GridLayout;import javax.swing.JButton;
    import javax.swing.JFrame;public class Framedemo extends JFrame {
    public Framedemo() {
    super("adasdasda");
    setDaxiao();
    setVisible(true);
    } private void setDaxiao() {
    setSize(140, 100);
    setLayout(new GridLayout(2,2));
    add(new JButton("44444444444"));
    add(new JButton("333333333"));
    add(new JButton("22222222"));
    add(new JButton("11111111"));
    } public static void main(String[] args) {
    new Framedemo();
    }
    }
      

  3.   

    用布局管理器就行了
    GridLayout
    BorderLayout
    GridBagLayout