标签:
public class FlowLayoutPosition extends JFrame{
public FlowLayoutPosition()
{
setTitle("本窗体使用流布局管理器");
Container c=getContentPane();
//设置窗体使用流布局,使用组件右对齐,并设置组件之间的水平间隔与垂直间隔
setLayout(new FlowLayout(2, 10, 10));
for (int i = 0; i < 10; i++) {
c.add(new JButton("button"+i));
}
setSize(300, 200);
setVisible(true);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new FlowLayoutPosition();
}
}
标签:
原文地址:http://www.cnblogs.com/douyunqian3520/p/5517397.html