/** |
* 功能:FlowLayout的简单案例 |
*/ |
package com.jiemian; |
import java.awt.*; |
import javax.swing.*; |
public class Text2 extends JFrame{ |
JButton jb1,jb2,jb3,jb4,jb5,jb6; |
public static void main(String[] args) { |
|
Text2 text2= new Text2(); |
} |
|
public Text2(){ |
|
jb1= new JButton( "宋江" ); |
jb2= new JButton( "吴用" ); |
jb3= new JButton( "李逵" ); |
jb4= new JButton( "林冲" ); |
jb5= new JButton( "武松" ); |
jb6= new JButton( "张飞" ); |
|
//设置布局管理器 |
this .setLayout( new FlowLayout(FlowLayout.CENTER)); |
|
//添加组件 |
this .add(jb1); |
this .add(jb2); |
this .add(jb3); |
this .add(jb4); |
this .add(jb5); |
this .add(jb6); |
|
//对刹窗体设置 |
this .setTitle( "流式布局案例" ); |
this .setSize( 300 , 200 ); |
this .setLocation( 200 , 100 ); |
//禁止改变窗体大小 |
this .setResizable( false ); |
this .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
//显示 |
this .setVisible( true ); |
} |
} |