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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • STM32看门狗详解[通俗易懂]

    STM32看门狗详解[通俗易懂]看门狗的作用:防止单片机因未知原因死机或比我们预期的时间过长长时间不能响应,如果出现这种问题,看门狗就会把单片机复位独立看门狗(IWDG):时钟来源:内部低速时钟(LSI),所以用看门狗时不需要配置时钟一般配置过程:寄存器:IWDG_KR:32位寄存器,低16位有效,只写写入0xAAAA,喂狗0x5555,取消IWDG_PR、IWDG_RLR的写保护0xCCCC,启动看门狗IWDG_PR:32位寄存器,低3位有效配置分频系数,4*2^prer.

    2022年4月30日
    69
  • 2021.4.14永久激活码_通用破解码

    2021.4.14永久激活码_通用破解码,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月16日
    1.4K
  • NetBIOS主机名扫描工具nbtscan「建议收藏」

    NetBIOS主机名扫描工具nbtscan「建议收藏」NetBIOS主机名扫描工具nbtscan

    2022年8月30日
    0
  • ServletContextListener

    ServletContextListenerServletContextListener的用法这个J2EE小提示阐述了ServletContextListener的用法。这个事件类作为Web应用服务的一部分,处理Web应用的servlet上下文(context)的变化的通知。这可以解释为,好像有个人在服务器旁不断地通知我们服务器在发生什么事件。那当然需要监听者了。因此,在通知上下文(context)初始化和销毁的时候,Servl

    2022年6月14日
    29
  • 如何获取uuid_uuid是怎么生成的

    如何获取uuid_uuid是怎么生成的item.id=UUID.randomUUID().toString();

    2022年8月10日
    4
  • acwing-1088旅行问题

    acwing-1088旅行问题原题链接John 打算驾驶一辆汽车周游一个环形公路。公路上总共有 n 个车站,每站都有若干升汽油(有的站可能油量为零),每升油可以让汽车行驶一千米。John 必须从某个车站出发,一直按顺时针(或逆时针)方向走遍所有的车站,并回到起点。在一开始的时候,汽车内油量为零,John 每到一个车站就把该站所有的油都带上(起点站亦是如此),行驶过程中不能出现没有油的情况。任务:判断以每个车站为起点能否按条件成功周游一周。输入格式第一行是一个整数 n,表示环形公路上的车站数;接下来 n 行,每行两个整数

    2022年8月9日
    2

发表回复

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

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