java swt griddata_[代码全屏查看]-SWT中GridLayout 和GridData的使用
[1].[代码] [Java]代码
package cn.haibin.rcp.test.layer;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ExpandBar;
import org.eclipse.swt.widgets.ExpandItem;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
/**
* GridLayout 布局测试示例
* @author cn.haibin
*
*/
public class TestGridLayout {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("布局测试");
shell.setSize(600, 400);
GridLayout layer = new GridLayout();
layer.numColumns = 2;
layer.makeColumnsEqualWidth = false;
layer.marginWidth = 5;
layer.marginHeight = 5;
layer.verticalSpacing = 0;
layer.horizontalSpacing = 1;
shell.setLayout(layer);
GridData treeGridData = new GridData(GridData.FILL_VERTICAL);
treeGridData.widthHint = 200;
Tree tree = new Tree(shell, SWT.SINGLE);
tree.setLayoutData(treeGridData);
TreeItem depart1 = new TreeItem(tree, SWT.NONE);
depart1.setText("开发部门");
{
TreeItem info1 = new TreeItem(depart1, SWT.NONE);
info1.setText("软件工程师");
TreeItem info2 = new TreeItem(depart1, SWT.NONE);
info2.setText("测试工程师");
}
TreeItem depart2 = new TreeItem(tree, SWT.NONE);
depart2.setText("市场部");
{
TreeItem info3 = new TreeItem(depart2, SWT.NONE);
info3.setText("产品");
TreeItem info4 = new TreeItem(depart2, SWT.NONE);
info4.setText("运营");
}
GridData expandBarGridData = new GridData(GridData.FILL_BOTH);
expandBarGridData.widthHint = 300;
ExpandBar expandBar = new ExpandBar(shell, SWT.V_SCROLL);
expandBar.setLayoutData(expandBarGridData);
{
Composite comp1 = new Composite(expandBar, SWT.NONE);
comp1.setLayout(new GridLayout(2, false));
Group group = new Group(comp1, SWT.NONE);
group.setText("增加部门");
Label lb_departCode = new Label(group, SWT.NONE);
lb_departCode.setBounds(10, 30, 100, 25);
lb_departCode.setText("部门代码");
Text txt_departCode = new Text(group, SWT.BORDER);
txt_departCode.setBounds(110, 30, 100, 25);
Label lb_departName = new Label(group, SWT.NONE);
lb_departName.setBounds(10, 60, 100, 25);
lb_departName.setText("部门名称");
Text txt_departName = new Text(group, SWT.BORDER);
txt_departName.setBounds(110, 60, 100, 25);
Button btn_ok = new Button(group, SWT.NONE);
btn_ok.setBounds(10, 90, 100, 25);
btn_ok.setText("OK");
Button btn_cancel = new Button(group, SWT.NONE);
btn_cancel.setBounds(110, 90, 100, 25);
btn_cancel.setText("Cancel");
new Label(comp1, SWT.NONE);
Group group1 = new Group(comp1, SWT.NONE);
group1.setText("部门信息");
final TableViewer tableViewer = new TableViewer(group1,
SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
Table table = tableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
table.setBounds(10, 40, 400, 100);
final TableColumn newColumnTableColumn = new TableColumn(table, SWT.NONE);
newColumnTableColumn.setWidth(120);
newColumnTableColumn.setText("部门代码");
final TableColumn newColumnTableColumn_1 = new TableColumn(table, SWT.NONE);
newColumnTableColumn_1.setWidth(120);
newColumnTableColumn_1.setText("部门名称");
Label lb_departCode1 = new Label(group1, SWT.NONE);
lb_departCode1.setBounds(10, 140, 100, 25);
lb_departCode1.setText("部门代码");
Button btn_departCode = new Button(group1, SWT.BORDER);
btn_departCode.setBounds(110, 140, 100, 25);
btn_departCode.setText("查询");
ExpandItem item1 = new ExpandItem(expandBar, SWT.NONE);
item1.setText("部门管理");
item1.setHeight(400);// 设置Item的高度
item1.setControl(comp1);// setControl方法控制comp1的显现
}
{
Composite comp2 = new Composite(expandBar, SWT.NONE);
ExpandItem item1 = new ExpandItem(expandBar, SWT.NONE);
item1.setText("岗位管理");
item1.setHeight(95);// 设置Item的高度
item1.setControl(comp2);// setControl方法控制comp1的显现
}
{
Composite comp3 = new Composite(expandBar, SWT.NONE);
comp3.setLayout(new GridLayout());
ExpandItem item1 = new ExpandItem(expandBar, SWT.NONE);
item1.setText("人员管理");
item1.setHeight(50);// 设置Item的高度
item1.setControl(comp3);// setControl方法控制comp1的显现
}
shell.open();
while (!shell.isDisposed()) {
if (display.readAndDispatch()) {
display.sleep();
}
}
}
}
java swt griddata_[代码全屏查看]-SWT中GridLayout 和GridData的使用相关推荐
- 申通快递java工资_[代码全屏查看]-java查询申通快递
[1].[代码] 用到了htmlunit的架包 package org.sjcx.tool; import com.gargoylesoftware.htmlunit.NicelyResynchron ...
- Java编写抓取用户信息代码_[代码全屏查看]-一个基于JAVA的知乎爬虫,抓取知乎用户基本信息...
[1].[代码] [Java]代码 作者:卧颜沉默 链接:https://www.zhihu.com/question/36909173/answer/97643000 来源:知乎 著作权归作者所有. ...
- java 查询线程池_[代码全屏查看]-我的 Java 线程池测试类
[1].[代码] TestThreadPool.java package net.oschina.tester; import java.io.Serializable; import java.ut ...
- java 面板 选择颜色_[代码全屏查看]-java颜色选择器
[1].[代码] [Java]代码 package com.liuxing.test; import java.awt.Color; import java.awt.event.ActionEvent ...
- java 俄罗斯方块窗口_[代码全屏查看]-java 俄罗斯方块
[1].[代码] [Java]代码 package com; import java.awt.Color; import java.awt.Graphics; import java.awt.even ...
- jquery java aes_[代码全屏查看]-java、js之间使用AES加密通信数据
[1].[代码] java AES加密解密辅助类 package com.zoki.security; import ch.qos.logback.classic.Logger; import jav ...
- java lock代码写法_[代码全屏查看]-java lock的使用
[1].[代码] [Java]代码 package boom; import java.util.concurrent.TimeUnit; import java.util.concurrent.lo ...
- java中两个数之差的绝对值_[代码全屏查看]-java 编程题(求两个数组中字符串长度之差绝对值最大)...
[1].[代码] [Java]代码 package codewars; import java.util.HashMap; import java.util.Map; /** * 问题描述 * * Y ...
- 加油卡 格式判断 java_[代码全屏查看]-基于JAVA的加油卡充值接口调用代码实例...
[1].[代码] [Java]代码 import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOE ...
最新文章
- 登陆共享服务器的位置,共享服务器哪里登陆
- 不小心关闭了explorer.exe进程,桌面变白解决办法
- echart饼图标签重叠_Echarts 解决饼图文字过长重叠的问题
- 重要的是改变命运,而非升职加薪
- Java Exe生成工具 JSmooth
- wincc和matlab通信,Matlab与WinCC之间的数据通信.doc
- C++ error: use of deleted function ‘std::atomic<short unsigned int>::atomic(const std::atomic<short
- unity 视频播放器没有声音
- Android面试题4
- 使用Java合并excel的sheet的操作
- Excel创建指定名称的单个工作表的3种操作
- [Unity ECS] 游戏对象转换和子场景 [1]
- 【20220207】【信号处理】三次样条插值原理详解
- 西门子触摸屏数据历史数据记录_西门子触摸屏mp277历史数据丢失(免费技术支持)...
- 163邮箱哪个安全好用?常用的电子邮箱品牌有哪些?
- 全行业聚合支付平台接口_各类API聚合支付平台
- Cisco ACS AAA认证
- Python实现打砖块小游戏
- 详解:alpine apk修改镜像源
- CronExpression_CronExpression 规则