JAVA 网格布局管理器
//网格布局管理器
import java.awt.*;
import javax.swing.*;
public class Jiemian3 extends JFrame{ //定义组件
JButton[] an = {null,null,null,null,null,null,null,null}; public static void main(String[] args){
//运行本类的构造方法
Jiemian3 jiemian = new Jiemian3(); } public Jiemian3(){ //创建按钮
an[0] = new JButton("话梅");
an[1] = new JButton("果铺");
an[2] = new JButton("薯片");
an[3] = new JButton("饼干");
an[4] = new JButton("巧克力");
an[5] = new JButton("腰果");
an[6] = new JButton("锅巴");
an[7] = new JButton("开心果"); //网格布局管理器声明
//第一个参数是行,第二个参数是列,第三个参数是横间距,第四个参数是竖间距
this.setLayout(new GridLayout(3,3,15,15)); //添加按钮
this.add(an[0]);
this.add(an[1]);
this.add(an[2]);
this.add(an[3]);
this.add(an[4]);
this.add(an[5]);
this.add(an[6]);
this.add(an[7]); //设置窗口标题
this.setTitle("网格布局Gridlayout");
//设置窗口的宽高
this.setSize(300,300);
//设置窗口出现对于屏幕的位置
this.setLocation(100,100);
//禁止拉大拉小
this.setResizable(false);
//关闭窗口后释放资源
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//输出窗口
this.setVisible(true);
} }
//网格布局管理器import java.awt.*;import javax.swing.*;public class Jiemian3 extends JFrame{//定义组件JButton[]an={null,null,null,null,null,null,null,null};public static void main(String[] args){//运行本类的构造方法Jiemian3 jiemian=new Jiemian3();}public Jiemian3(){//创建按钮an[0]=new JButton("话梅");an[1]=new JButton("果铺");an[2]=new JButton("薯片");an[3]=new JButton("饼干");an[4]=new JButton("巧克力");an[5]=new JButton("腰果");an[6]=new JButton("锅巴");an[7]=new JButton("开心果");//网格布局管理器声明//第一个参数是行,第二个参数是列,第三个参数是横间距,第四个参数是竖间距this.setLayout(new GridLayout(3,3,15,15));//添加按钮this.add(an[0]);this.add(an[1]);this.add(an[2]);this.add(an[3]);this.add(an[4]);this.add(an[5]);this.add(an[6]);this.add(an[7]);//设置窗口标题this.setTitle("网格布局Gridlayout");//设置窗口的宽高this.setSize(300,300);//设置窗口出现对于屏幕的位置this.setLocation(100,100);//禁止拉大拉小this.setResizable(false);//关闭窗口后释放资源this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//输出窗口this.setVisible(true);}}
JAVA 网格布局管理器的更多相关文章
- java网格布局管理器
public class GirdLayoutPosition extends JFrame{ public GirdLayoutPosition() { Container ...
- Java基础之创建窗口——使用网格布局管理器(TryGridLayout)
控制台程序. 网格布局管理器可以在容器的矩形网格中布局组件. import javax.swing.*; import java.awt.*; import javax.swing.border.Et ...
- JAVA简单的网格布局管理器--JAVA基础
网格布局管理器: GridLayoutDemo.java: import java.awt.GridLayout;import javax.swing.JButton;import javax.swi ...
- 编写Java程序,将JButton按钮按网格布局管理器格式放置
返回本章节 返回作业目录 需求说明: 将JButton按钮按网格布局管理器格式放置 实现思路: 实现代码: public void init(){ setLayout(new GridLayout(4 ...
- java基础 布局管理器
概念: 组建在容器(比如JFrame)中的位置和 大小 是由布局管理器来决定的.所有的容器都会使用一个布局管理器,通过它来自动进行组建的布局管理. 种类: java共提供了物种布局管理器:流式布局管理 ...
- JAVA GUI布局管理器
边界布局管理器: a.布局方式:是把整个容器划分为五个部分.东西南北中,南北要贯通,中间最大 (不仅是中间的范围最大,权利也最大)当周边不存在的时候中间会占领周边,当中间不存在的时候周边不能占据中间 ...
- python之tkinter使用-Grid(网格)布局管理器
# 使用tkinter编写登录窗口 # Grid(网格)布局管理器会将控件放置到一个二维的表格里,主控件被分割为一系列的行和列 # stricky设置对齐方式,参数N/S/W/E分别表示上.下.左.右 ...
- Java 的布局管理器GridBagLayout的使用方法(转)
GridBagLayout是java里面最重要的布局管理器之一,可以做出很复杂的布局,可以说GridBagLayout是必须要学好的的, GridBagLayout 类是一个灵活的布局管理器,它不要求 ...
- 5、Java Swing布局管理器(FlowLayout、BorderLayout、CardLayout、BoxLayout、GirdBagLayout 和 GirdLayout)
5.Java-Swing常用布局管理器 应用布局管理器都属于相对布局,各组件位置可随界面大小而相应改变,不变的只是其相对位置,布局管理器比较难以控制,一般只在界面大小需要改是才用,但即使这 ...
随机推荐
- WebForm 中的页面重定向和传值(转自 MSDN)
——原文地址:https://msdn.microsoft.com/zh-cn/library/6c3yckfw(v=vs.100).aspx 在开发 ASP.NET 网站时,您经常需要从一 ...
- Scala vs. Groovy vs. Clojure
http://stackoverflow.com/questions/1314732/scala-vs-groovy-vs-clojure Groovy is a dynamically typed ...
- unity, 用unity profiler进行真机profile,需要退出360
用unity profiler进行真机profile,需要退出360.
- spring基于注解的配置文件
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- weblogic性能调优参考
1.weblogic内存的调优 2.weblogic性能调优 各个方面比较全内容较多 3.记录一次weblogic 11g压力测试性能调优过程 经调优后,具体java启动参数如下: /app/webl ...
- 【性能诊断】九、并发场景的性能分析(windbg案例,Fist Chance Exception/Crash dump)
经常会碰到这样的场景,自测及单单点的测试时没有任何问题,但在并发环境或生产环境下有时出现没规律的异常.报错等情况.在代码中增加日志是其中一种解决方式:抓取指定异常时的dump,通过wind ...
- FileDataSource java的文件操作
FileDataSource:(javax.activation.FileDataSource.FileDataSource(File file)) FileDataSource 类实现一个封装文件的 ...
- XAMPP 在windows下无法启动Apache解决方案
XAMPP 在windows下无法启动Apache解决方案 一.现象 XAMPP 点击Start Apache时出现如下错误 20:41:12 [Apache] Error: Apache shut ...
- NAT,网络地址转换详解
这个技术,是一个非常成熟的技术了,但是,为了将其弄得清楚点,体系点,也为了备忘,还是有必要在这里梳理一下! NAT:Network Address Translation. 这个主要是用在网络地址(I ...
- (转载)postgresql navicat 客户端连接验证失败解决方法:password authentication failed for user
命令:su - postgres CREATE USER foo WITH PASSWORD 'secret'; ==================== 1.2个配置修改 postgresql.co ...