Document

/**
* 功能:流式布局案例
*/
package com.test1;

import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;

public class Demo8_3 extends JFrame {
//定义组件
JButton jb1,jb2,jb3,jb4,jb5,jb6;

public static void main(String[] args){
Demo8_3 demo8_3=new Demo8_3();
}


public Demo8_3(){
//创建组件
jb1=new JButton("关飞0");
jb2=new JButton("关飞1");
jb3=new JButton("关飞2");
jb4=new JButton("关飞3");
jb5=new JButton("关飞4");
jb6=new JButton("关飞5");
//添加组件
this.add(jb1);
this.add(jb2);
this.add(jb3);
this.add(jb4);
this.add(jb5);
this.add(jb6);
//设置布局管理器
this.setLayout(new FlowLayout(FlowLayout.RIGHT));
//设置窗体的属性
this.setTitle("边距布局案例");
this.setSize(350,200);
this.setLocation(200,200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//显示
this.setVisible(true);
}
}

原文地址:https://www.cnblogs.com/chenyanlong/p/6942178.html