GridBagLayout占多行效果注意
如果想要出现按钮2占两行的效果,必须按键3、按钮4同时存在且同时可见。
- 如果缺少按钮4,则按钮2不会占两行;
- 如果缺少按钮3、4,则按钮2也不会占两行。
package com.wst.bj; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import javax.swing.JButton;
import javax.swing.JFrame; class GridBagText { JFrame jframe = new JFrame("搜索"); JButton jButton = new JButton("按钮1");
JButton jButton2 = new JButton("按钮2");
JButton jButton3 = new JButton("按钮3");
JButton jButton4 = new JButton("按钮4"); public GridBagText() { init();
} private void init()
{
FrameUtil.initFram(jframe, 500, 700); GridBagLayout gridBagLayout = new GridBagLayout();
jframe.setLayout(gridBagLayout);
GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH;
constraints.weightx = 1.0;
constraints.weighty = 1.0; constraints.gridheight = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridBagLayout.setConstraints(jButton, constraints);
jframe.add(jButton); constraints.gridheight = 2;
constraints.gridwidth = 1;
gridBagLayout.setConstraints(jButton2, constraints);
jframe.add(jButton2); constraints.gridheight = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridBagLayout.setConstraints(jButton3, constraints);
jframe.add(jButton3);
gridBagLayout.setConstraints(jButton4, constraints);
jframe.add(jButton4); jframe.setSize(jframe.getPreferredSize());
jframe.setVisible(true);
// jframe.pack();
}
}
package com.wst.bj; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import javax.swing.JButton;
import javax.swing.JFrame; class GridBagText { JFrame jframe = new JFrame("搜索"); JButton jButton = new JButton("按钮1");
JButton jButton2 = new JButton("按钮2");
JButton jButton3 = new JButton("按钮3");
// JButton jButton4 = new JButton("按钮4"); public GridBagText() { init();
} private void init()
{
FrameUtil.initFram(jframe, 500, 700); GridBagLayout gridBagLayout = new GridBagLayout();
jframe.setLayout(gridBagLayout);
GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH;
constraints.weightx = 1.0;
constraints.weighty = 1.0; constraints.gridheight = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridBagLayout.setConstraints(jButton, constraints);
jframe.add(jButton); constraints.gridheight = 2;
constraints.gridwidth = 1;
gridBagLayout.setConstraints(jButton2, constraints);
jframe.add(jButton2); constraints.gridheight = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridBagLayout.setConstraints(jButton3, constraints);
jframe.add(jButton3);
// gridBagLayout.setConstraints(jButton4, constraints);
// jframe.add(jButton4); jframe.setSize(jframe.getPreferredSize());
jframe.setVisible(true);
// jframe.pack();
}
}
package com.wst.bj; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import javax.swing.JButton;
import javax.swing.JFrame; class GridBagText { JFrame jframe = new JFrame("搜索"); JButton jButton = new JButton("按钮1");
JButton jButton2 = new JButton("按钮2");
// JButton jButton3 = new JButton("按钮3");
// JButton jButton4 = new JButton("按钮4"); public GridBagText() { init();
} private void init()
{
FrameUtil.initFram(jframe, 500, 700); GridBagLayout gridBagLayout = new GridBagLayout();
jframe.setLayout(gridBagLayout);
GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH;
constraints.weightx = 1.0;
constraints.weighty = 1.0; constraints.gridheight = 1;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridBagLayout.setConstraints(jButton, constraints);
jframe.add(jButton); constraints.gridheight = 2;
constraints.gridwidth = 1;
gridBagLayout.setConstraints(jButton2, constraints);
jframe.add(jButton2); // constraints.gridheight = 2;
// constraints.gridwidth = GridBagConstraints.REMAINDER;
// gridBagLayout.setConstraints(jButton3, constraints);
// jframe.add(jButton3);
// gridBagLayout.setConstraints(jButton4, constraints);
// jframe.add(jButton4); jframe.setSize(jframe.getPreferredSize());
jframe.setVisible(true);
// jframe.pack();
}
}
GridBagLayout占多行效果注意的更多相关文章
- linkbutton datagrid showdialog 行效果
protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e) { ListItemType itemTy ...
- SQL Server查询所有的表名/空间占用量/行数
select object_name(id) tablename, 8*reserved/1024 reserved, rtrim(8*dpages)+'kb' used, 8*(reserved-d ...
- android TextView字体设置最少占多少行. 及其 Java String 字符串操作 . .
① 字体设置: 修改代码 : GridViewActivity.java priceTv为 TextView priceTv.setMaxLines(3); //当多与7个字fu的时候 , 其余字 ...
- sqlserver查询数据的所有表名和行数及空间占用量
//查询所有表名 select name from sysobjects where xtype='u' --modify_date指表结构最后更新日期,并非数据最后更新日期SELECT na ...
- webpages框架中使用Html.TextArea()在前台显示多行信息时,如何进行大小、样式的设置
环境:vs2015 webpages框架+razor语法: 目的:服务器进行数据更新操作后,在前台显示更新的相关信息: 后台代码:将更新条数等相关信息存储在一个变量中: @{ var serverIn ...
- 用VBA计算WPS 表格ET EXCEL中的行数和列数的多重方法
用VBA计算WPS 表格ET EXCEL中的行数和列数 每种方法中上面的是Excel的行数,下面的是Excel的列数. 方法1: ActiveSheet.UsedRange.Rows.Count Ac ...
- VBA取得EXCEL表格中的行数和列数
VBA取得EXCEL表格中的行数和列数 初学EXCEL宏的童鞋,总是很想知道表格中含有数据的行数和列数,尤其是行数和列数不确定的情况下.这样可以避免很多的错误,并且可以提高效率.但每次用到的时候到网上 ...
- C# 得到EXCEL表格中的有效行数和列数
每种方法中上面的是Excel的行数,下面的是Excel的列数.方法七:经过加工修改已经可以读出来的是有效数据行 using Excel = Microsoft.Office.Interop.Excel ...
- Office EXCEL VBA如何取得EXCEL中的行数和列数
VBA取得EXCEL表格中的行数和列数 请注意不要使用Columus等关键字作为变量,例如"Columus = ActiveSheet.UsedRange.Columns.Count&quo ...
随机推荐
- feof()
百度知道 >电脑/网络 >编程语言 >C/C++ feof()这个函数是用来判断指针是否已经到达文件尾部的. 若fp已经指向文件末尾,则feof(fp)函数值为"真&quo ...
- mysql增量备份 percona-xtrabackup
先说下实际环境 阿里云买的ESC跑的mysql服务,目前由于数据量过大,数据库目前有800多GB,每次全备需要等20多个小时才能够完成,然后就想到做增量备份,写下此文档 一.测试环境 [root@lo ...
- PC-常见问题-清除浮动
常用:.clear{clear:both;height:0px;overflow:hidden;}>最优浮动闭合方案(这是我们推荐的): .clearfix:after{content:&quo ...
- Biorhythms(中国剩余定理)
Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 127339 Accepted: 40342 Des ...
- 如何实现 iOS 自定义状态栏
给大家介绍如何实现 iOS 自定义状态栏 Sample Code: 01 UIWindow * statusWindow = [[UIWindow alloc] initWithFrame:[UIAp ...
- 分析NTFS文件系统得到特定文件的内容
找某一个文件的内容(如要读取文件D:\dir\dir2\text.txt,详细过程例如以下: (1)读取分区表/分区链表信息,找到磁盘F的起始扇区. (2)读取D盘的第一个扇区(分区的BOOTSETO ...
- js中取session的值
在js中貌似不能取session的值,我在后台设置的session一直拿不到,于是用间接的方式拿到session的值. 首先在jsp中嵌入java代码,用java设置一个变量来取session值,再在 ...
- php字符串标点等字符截取不乱吗 封装方法
方法一: /** +---------------------------------------------------------- * 功能:字符串截取指定长度 * leo.li hen ...
- dtree基础
最近用到了dtree来建立树,纠结过好久后,终于有了些门道,下面的总结希望对咪咪们有些帮助: dtree用来建立静态树或者动态树都是很方便的,老外给提供了整个的JS,然后我们只是操心这个树中存放的元素 ...
- UNION 和UNION ALL
UNION 操作符用于合并两个或多个 SELECT 语句的结果集. 请注意,UNION 内部的 SELECT 语句必须拥有相同数量的列.列也必须拥有相似的数据类型.同时,每条 SELECT 语句中的列 ...