package gui1;

import java.awt.FlowLayout;
import java.awt.GridLayout; import javax.swing.JButton;
import javax.swing.JFrame; public class gridlayout1 extends JFrame{
JButton [] a={null,null,null,null,null,null,null,null};
public static void main(String[] args) {
// TODO Auto-generated method stub
gridlayout1 g1=new gridlayout1();
}
public gridlayout1()
{ 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 GridLayout(,,,));//默认是边界布局,如果想变成其他布局,加上 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("网格布局gridlayout");
this.setSize(,);
this.setLocation(, );
this.setResizable(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true); }
}

swing之gridlayout的更多相关文章

  1. java在线聊天项目0.2版本 制作客户端窗体,使用swing(用户界面开发工具包)和awt(抽象窗口工具包) BorderLayout布局与GridLayout布局不同之处 JPanel设置大小

    代码如下: package com.swift; import java.awt.BorderLayout; import java.awt.Color; import javax.swing.JBu ...

  2. 如何使用swing创建一个BeatBox

    首先,我们需要回顾一些内容(2017-01-04 14:32:14): 1.Swing组件 Swing的组件(component,或者称之为元件),是较widget更为正确的术语,它们就是会放在GUI ...

  3. Java Swing interview

    http://www.careerride.com/Swing-AWT-Interview-Questions.aspx   Swing interview questions and answers ...

  4. Swing布局管理器介绍

    创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://zhangjunhd.blog.51cto.com/113473/128174 当选 ...

  5. java基础 swing编程实战

    1. 实现金山词霸,点击左右收缩 效果图: exmaple code : /* * 词霸 * */ package demo7; import java.awt.*; import java.awt. ...

  6. Java Swing 第03记 布局管理器

    几种Swing常用的布局管理器 BorderLaout 它将容器分为5个部分,即东.南.西.北.中,每一个区域可以容纳一个组件,使用的时候也是通过BorderLayout中5个方位常量来确定组件所在的 ...

  7. Java——Swing事件处理

    import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import javax.swing.JFrame; ...

  8. 总结-swing、JFrame、JScrollPane、JTabbedPane、JEditorPane

    总结-swing.JFrame.JButton.JScrollPane.JLabel.JTabbedPane.JEditorPane 1.JButton内边距(去掉按钮里的空白):setMargin2 ...

  9. 【Swing】理解Swing中的事件与线程

    talk is cheap , show me the code. Swing中的事件 事件驱动 所有的GUI程序都是事件驱动的.Swing当然也是. GUI程序不同于Command Line程序,一 ...

随机推荐

  1. Sourse Insight使用过程中的常使用功能简介

    1.查找定义: 在编辑区内,选中任意一个变量.函数.宏等,点击右键->Jump Definition,或者直接Ctrl+左击 2.编辑区切换

  2. layer满屏/禁止最大化最小化 可以做选择框使用

    1.layer弹窗最大化 var index=layer.open(); layer.full(index); 2.layer禁止最大化最小化 layer.open( [ type:2, title: ...

  3. LVS/DR 配置

    LVS/DR 配置 实验环境 三台主机:Linux Centos 6.4 32位 调度器Director:192.168.1.160(公网IP).192.168.1.100(VIP) HTTP真实服务 ...

  4. 离乡与理想 Demo

    离乡与理想---理想不分黑白 踏上了火车,离开家乡背着幻梦,站累了有人叫我幸福,叫我快乐而我是没有名字的流浪的日子,已数不清有多少带着理想,一路飞翔路上遇见困难,一定要坚强因为理想已离乡 我为理想而离 ...

  5. readonly与disabled

    readonly与disabled都能将元素设为不可编辑状态,但他们有许多区别: 1.样式 readonly与一般样式一样,disabled会将元素背景设为灰色 2.应用范围 readonly只对in ...

  6. CentOS 7 安装 docker-machine

    https://github.com/docker/machine/releases/ 指令: curl -L https://github.com/docker/machine/releases/d ...

  7. html里id和name的异同

    id与name的作用,作为标签的标识符,基本上是一样的. name是老方法,id是在name基础上发明的,比name“现代化”一点,用的范围广一点 <...>中的name原来(刚发明时)就 ...

  8. Codeforces Round #273 (Div. 2) D. Red-Green Towers 背包dp

    D. Red-Green Towers time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  9. PHP使用header+Location实现网站301重定向

    对于我们SEO人员来说,有的时候需要对网站进行重定向.一般来说,对网站重定向的http返回状态码是301和302两种.下面兰州SEO就通过实例来为你介绍一下怎样通过PHP使用header+Locati ...

  10. ThreadPool(线程池)

    WPF使用ThreadPool.QueueUserWorkItem线程池防界面假死 时间:2012-01-09 20:44来源:http://luacloud.com 作者:luacloud 点击:1 ...