java swt griddata_SWT中GridLayout 和GridData的使用

java swt griddata_SWT中GridLayout 和GridData的使用1.[代码][Java]代码packagecn.haibin.rcp.test.layer;importorg.eclipse.jface.viewers.TableViewer;importorg.eclipse.swt.SWT;importorg.eclipse.swt.layout.GridData;importorg.eclipse.swt.layout.GridLayout;i…

大家好,又见面了,我是你们的朋友全栈君。

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();

}

}

}

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/141354.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • matlab插值实验目的,matlab插值实验报告数学实验.doc

    matlab插值实验目的,matlab插值实验报告数学实验.docmatlab插值实验报告数学实验.doc新乡学院数学与信息科学系实验报告实验项目名称插值实验所属课程名称数学实验实验类型综合性实验实验日期班级学号姓名成绩一、实验概述【实验目的】掌握用MATLAB插值的方法,了解拉格朗日插值、线性插值、样条插值的基本思想,了解三种网格节点数据的插值方法的基本思想,了解掌握用MATLAB计算一维差值和二维插值的方法。【实验原理】拉格朗日LAGRANGE插值。已知函…

    2022年5月26日
    37
  • wrk 压测工具

    wrk 压测工具wrk 压测工具安装 gitclonehttp github com wg wrk gitcdwrkmake 常用参数类型 Usage wrk options url Options c connections N Connectionst d duration T Durationofte e g 2s 2m 2h T N url options

    2025年11月5日
    1
  • Fiddler抓取视频数据「建议收藏」

    准备工作:(1)、手机(安卓、ios都可以)/安卓模拟器,今天主要以安卓模拟器为主,操作过程一致。(2)、抓包工具:Fiddel下载地址:(https://www.telerik.com/download/fiddler)(3)、编程工具:pycharm(4)、安卓模拟器上安装抖音(逍遥安装模拟器)一、fiddler配置在tools中的options中,按照图中勾选后点击Actio…

    2022年4月8日
    883
  • Log4net中ConversionPattern的代码解释[通俗易懂]

    Log4net中ConversionPattern的代码解释[通俗易懂]      layout type=”log4net.Layout.PatternLayout”>        param name=”Header” value=”———————–header————————–” />        param name=”Footer” value=”——————–

    2022年8月22日
    12
  • Wireshark过滤规则的使用!「建议收藏」

    Wireshark过滤规则的使用!「建议收藏」文章目录MAC地址过滤显示包含的MAC地址只显示源MAC地址只显示目标MAC地址IP地址过滤显示包含的IP地址只显示源IP地址只显示目标IP地址端口号过滤显示包含端口号为80的报文只显示源端口号为80的报文只显示目标端口号为80的报文过滤高层协议语法MAC地址过滤显示包含的MAC地址eth.addr==38:b1:db:d4:41:c5不管是源MAC地址还是目标MAC地址,只要包含38:b1:db:d4:41:c5的MAC地址都会显示出来只显示源MAC地址eth.src==38:b1:

    2022年7月13日
    24
  • django的安装_django部署

    django的安装_django部署DRF介绍DRF是DjangoRestFramework单词的简写,是在Django框架中实现RestfulAPI的一个插件,使用他可以非常方便的实现接口数据的返回。Django中也可以使用J

    2022年8月7日
    5

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号