当前位置: 首页 > news >正文

5、布局管理器

5、布局管理器

一、流式布局

package com.dryant.lesson1;import java.awt.*;public class TestFlowLayout {public static void main(String[] args) {Frame frame = new Frame();Button button1 = new Button("bt1");Button button2 = new Button("bt2");Button button3 = new Button("bt3");Button button4 = new Button("bt4");Button button5 = new Button("bt5");//frame.setLayout(new FlowLayout());设置流式布局frame.setLayout(new FlowLayout(FlowLayout.LEFT));//设置流式布局左对齐frame.setSize(200,200);frame.add(button1);frame.add(button2);frame.add(button3);frame.add(button4);frame.add(button5);frame.setVisible(true);}
}

二、东西南北中布局

package com.dryant.lesson1;import java.awt.*;public class TestBorderLayout {public static void main(String[] args) {Frame frame = new Frame();///frame.setLayout(new BorderLayout());frame.setSize(500,500);Button button1 = new Button("east");Button button2 = new Button("按钮西");Button button3 = new Button("按钮南");Button button4 = new Button("按钮北");Button button5 = new Button("按钮中");frame.setVisible(true);frame.add(button1,BorderLayout.EAST);frame.add(button2,BorderLayout.WEST);frame.add(button3,BorderLayout.SOUTH);frame.add(button4,BorderLayout.NORTH);frame.add(button5,BorderLayout.CENTER);}
}

三、表格布局

package com.dryant.lesson1;import java.awt.*;public class TestGridLayout {public static void main(String[] args) {Frame frame = new Frame();Button btn1 = new Button("btn1");Button btn2 = new Button("btn2");Button btn3 = new Button("btn3");Button btn4 = new Button("btn4");Button btn5 = new Button("btn5");Button btn6 = new Button("btn6");frame.setLayout(new GridLayout(3,2));frame.add(btn1);frame.add(btn2);frame.add(btn3);frame.add(btn4);frame.add(btn5);frame.add(btn6);frame.setVisible(true);frame.setSize(300,300);}
}
http://www.lryc.cn/news/178692.html

相关文章:

  • What is a UDP Flood Attack?
  • 多核 ARM Server 性能调优
  • oracle执行计划中,同一条语句块,在不同情况下执行计划不一样问题。子查询,union 导致索引失效。
  • 【新的小主机】向日葵远程控制ubuntu
  • 在Android studio高版本上使用低版本的Github项目库报错未能解析:Landroid/support/v4/app/FrageActivity;
  • 自动混剪多段视频、合并音频、添加文案的技巧分享
  • 学习笔记——BSGS
  • 【AI视野·今日NLP 自然语言处理论文速览 第四十期】Mon, 25 Sep 2023
  • Linux C/C++下收集指定域名的子域名信息(类似dnsmap实现)
  • linux-定时任务
  • 在Spring Boot项目中使用Redisson
  • JavaScript 函数柯里化
  • springboot实现ACL+RBAC权限体系
  • C++20协程示例
  • 【Verilog 教程】6.2Verilog任务
  • Spring修炼之路(1)基础入门
  • GANs学习记录
  • Flink-CDC——MySQL、SqlSqlServer、Oracle、达梦等数据库开启日志方法
  • linux设置tomcat redis开机自启动
  • 跨域问题讨论
  • ESP32设备通信-两个ESP32设备之间HTTP通信
  • 数据结构学习笔记——查找算法中的树形查找(平衡二叉树)
  • P1830 轰炸III
  • 大语言模型LLM知多少?
  • Redis命令行使用Lua脚本
  • HTML详细基础(三)表单控件
  • map和set的具体用法 【C++】
  • 聚合统一,SpringBoot实现全局响应和全局异常处理
  • 【C/C++笔试练习】——数组名和数组名、switch循环语句、数据在计算机中的存储顺序、字符串中找出连续最长的数字串、数组中出现次数超过一半的数字
  • 力扣每日一题(+日常水题|树型dp)