swing之flowlayout
2024-10-20 03:32:42
import java.awt.FlowLayout; import javax.swing.JButton;
import javax.swing.JFrame;
//1.继承 JFrame类
//2.在最上方定义组件
//3.在构造方法中创建组件
//4、在构造方法中添加组件
//5.设置窗体属性
//6.显示窗体
//7.在主函数中创建对象 public class flowlayout1 extends JFrame{
JButton [] a={null,null,null,null,null,null,null,null};
public static void main(String[] args) {
// TODO Auto-generated method stub
flowlayout1 f1=new flowlayout1();
} public flowlayout1 ()
{
a[]=new JButton("瓜子");
a[]=new JButton("话梅");
a[]=new JButton("西瓜");
a[]=new JButton("草莓");
a[]=new JButton("香蕉");
a[]=new JButton("苹果");
a[]=new JButton("栗子");
a[]=new JButton("黄瓜");
//a[8]=new JButton("葡萄"); this.setLayout(new FlowLayout(FlowLayout.LEADING));//默认是边界布局,如果想变成其他布局,加上 this.add(a[]);
this.add(a[]);
this.add(a[]);
this.add(a[]);
this.add(a[]);
this.add(a[]);
this.add(a[]);
this.add(a[]); this.setTitle("流式布局flowlayout");
this.setSize(,);
this.setLocation(, );
this.setResizable(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true); }
}
最新文章
- JS实现页面加载完毕之前loading提示效果
- 用SysTick做的延时计时器
- 关于 mysqladmin
- iOS 详细解释@property和@synthesize关键字
- 悟透Javascript之 原型prototype
- 基于visual Studio2013解决C语言竞赛题之0517矩阵
- shell小脚本工具合集
- Android灯光系统--深入理解背光灯
- Unity 游戏框架搭建 (五) 简易消息机制
- Ionic3学习笔记(一)安装、项目结构与常用命令
- Jquery测试题
- 【转】Steam 开发者收入计算
- C#杂记-隐式类型的局部变量
- 判断语句之if...else
- Android常用的工具类SharedPreferences封装类SPUtils
- L1-061 新胖子公式
- pytest 1.简单介绍一,安装和如何运行
- GigE IP地址配置
- 图片路径中含有中文在jsp下不能正常显示的问题
- EXCEL行倒叙