标签:flow add 9.png 苹果 color image div 组件 location
import java.awt.FlowLayout; import javax.swing.JButton; import javax.swing.JFrame; //1.继承 JFrame类 //2.在最上方定义组件 //3.在构造方法中创建组件 //4、在构造方法中添加组件 //5.设置窗体属性 //6.显示窗体 //7.在主函数中创建对象 public class flowlayout1 extends JFrame{ JButton [] a={null,null,null,null,null,null,null,null}; public static void main(String[] args) { // TODO Auto-generated method stub flowlayout1 f1=new flowlayout1(); } public flowlayout1 () { a[0]=new JButton("瓜子"); a[1]=new JButton("话梅"); a[2]=new JButton("西瓜"); a[3]=new JButton("草莓"); a[4]=new JButton("香蕉"); a[5]=new JButton("苹果"); a[6]=new JButton("栗子"); a[7]=new JButton("黄瓜"); //a[8]=new JButton("葡萄"); this.setLayout(new FlowLayout(FlowLayout.LEADING));//默认是边界布局,如果想变成其他布局,加上 this.add(a[0]); this.add(a[1]); this.add(a[2]); this.add(a[3]); this.add(a[4]); this.add(a[5]); this.add(a[6]); this.add(a[7]); this.setTitle("流式布局flowlayout"); this.setSize(400,320); this.setLocation(100, 180); this.setResizable(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } }
标签:flow add 9.png 苹果 color image div 组件 location
原文地址:http://www.cnblogs.com/luo-mao/p/6030499.html