/** |
* 功能:多种布局管理器的使用 |
*/ |
package com.jiemian; |
import java.awt.*; |
import javax.swing.*; |
public class Text4 extends JFrame{ |
JPanel jp1,jp2; |
JButton jb1,jb2,jb3,jb4,jb5,jb6; |
|
public static void main(String[] args) { |
// TODO Auto-generated method stub |
Text4 text4= new Text4(); |
} |
|
public Text4(){ |
//创建组件 |
jp1 = new JPanel(); |
jp2 = new JPanel(); |
|
jb1 = new JButton( "苹果" ); |
jb2 = new JButton( "西瓜" ); |
jb3 = new JButton( "荔枝" ); |
jb4 = new JButton( "雪梨" ); |
jb5 = new JButton( "李子" ); |
jb6 = new JButton( "香蕉" ); |
|
//设置布局管理器 |
|
//添加组件 |
this .add(jp1,BorderLayout.NORTH); |
this .add(jp2,BorderLayout.SOUTH); |
this .add(jb6,BorderLayout.CENTER); |
|
jp1.add(jb1); |
jp1.add(jb2); |
jp2.add(jb3); |
jp2.add(jb4); |
jp2.add(jb5); |
|
//设置窗体 |
this .setSize( 300 , 200 ); |
this .setLocation( 200 , 100 ); |
this .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
this .setVisible( true ); |
} |
} |
初级程序员
by: 云代码会员 发表于:2016-10-15 20:43:45 顶(0) | 踩(0) 回复
布局管理器
回复评论