什么是无布局?如何实现?举了例好吗!谢谢

解决方案 »

  1.   

    contentPane.setLayout(new FlowLayout());contentPane.add(new JButton("Button 1"));
    contentPane.add(new JButton("Button 2"));
    contentPane.add(new JButton("Button 3"));
    contentPane.add(new JButton("Long-Named Button 4"));
    contentPane.add(new JButton("5"));
      

  2.   

    在使用“无布局管理器”时,首先要作出声明,即: 
      setLayout(null);
      然后用reshape()方法指定组件的具体位置和尺寸,
      基本语句如下所示:
      Label label1=new Label(); //定义标签
    this.add(label1);   //把标签加入布局管理器
    label1.reshape(10,10,30,30); //在指定位置绘制标签