静止的流水的学习日志
静止的流水
全部博文(210)
Windows(1)
Linux(31)
2011年(34)
2010年(121)
2009年(37)
2008年(18)
cynthia
wojiuzhu
jd_lzh
鄙人姓王
Jack_Tan
fanbiubi
猜我咯
aaccp1
chrisy52
分类: Java
2011-03-15 14:12:57
package com.utstar.factory;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;/** * FlowLayout按照添加控件的顺序按行来添加,默认中间对齐,可以在创建flowlayout的时候设定对其方式 * 一行放不下放第二行 * @author HZ20232 * */public class TestFlowLayout extends JFrame{ private static final long serialVersionUID = 6819222900970457455L; private JButton button1; private JButton button2; private JButton button3; private JButton button4; private JButton button5; private JButton button6; private JPanel panel; public TestFlowLayout(){ this.setSize(new Dimension(400,400)); this.setTitle("测试"); init(); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } private void init(){ button1 = new JButton("NORTH"); button2 = new JButton("SOUTH"); button3 = new JButton("EAST"); button4 = new JButton("WEST"); button5 = new JButton("CENTER"); button6 = new JButton("CENTER6"); panel = new JPanel(); FlowLayout myLayout = new FlowLayout(FlowLayout.LEFT);// FlowLayout myLayout = new FlowLayout(FlowLayout.RIGHT);// FlowLayout myLayout = new FlowLayout(FlowLayout.CENTER);// FlowLayout myLayout = new FlowLayout(FlowLayout.LEADING);// FlowLayout myLayout = new FlowLayout(FlowLayout.TRAILING); this.setLayout(myLayout); this.add(button1); this.add(button2); this.add(button3); this.add(button4); this.add(button5); this.add(button6); } public static void main(String args[]){ TestFlowLayout test = new TestFlowLayout(); }}
上一篇:Java Swing布局管理器GridLayout简单示例
下一篇:java swing页面传值及JTree和JTable用法简单示例
chinaunix网友2011-03-27 13:27:12
很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com
登录 注册