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


相关推荐

  • 图片url地址转换成file文件[通俗易懂]

    图片url地址转换成file文件[通俗易懂]publicstaticFilegetFile(Stringurl)throwsException{//对本地文件命名StringfileName=url.substring(url.lastIndexOf(“.”),url.length());Filefile=null;URLurlfile;InputStreaminStream=null;OutputStreamos=null;try{

    2022年9月22日
    5
  • PHP如何实现百万级数据导出

    PHP如何实现百万级数据导出

    2021年11月3日
    52
  • java与数据库连接的步骤_java与数据库的连接怎么实现

    java与数据库连接的步骤_java与数据库的连接怎么实现1.加载驱动Class.forname(数据库驱动名);2.建立数据库连接使用DriverManager类的getConnection()静态方法来获取数据库连接对象,其语法格式如下所示:Connectionconn=DriverManager.getConnection(Stringurl,Stringuser,Stringpass);其中url–数据库连接字符串….

    2025年12月8日
    5
  • Java基准测试工具JMH使用

    Java基准测试工具JMH使用JMH,即JavaMicrobenchmarkHarness,这是专门用于进行代码的微基准测试的一套工具API。JMH由OpenJDK/Oracle里面那群开发了Java编译器的大牛们所开发。何谓MicroBenchmark呢?简单地说就是在方法层面上的benchmark,精度可以精确到微秒级。本文主要介绍了性能基准测试工具JMH,它可以通过一些功能来规避由JVM中的JIT或者其他优化对性能测试造成的影响。

    2022年7月27日
    7
  • UltraEdit Crack,完全集成的编辑和数据管理工具

    UltraEdit Crack,完全集成的编辑和数据管理工具UltraEditCrack,完全集成的编辑和数据管理工具  UltraEditAllAccess订阅许可证(原IDMAllAccess订阅)为您提供世界领先的文件管理解决方案,从文件的创建到最终的存储、停用和删除,UltraEditAllAccess是一个集成的、端到端的数百万人信赖的解决方案。在UltraEdit或UEStudio中开发您的文本。使用UltraCompare查找和管理差异。使用UltraFinder快速查找丢失的文件或您需要的确切字符串,并使用

    2025年7月26日
    3
  • JSON字符串转对象_微信小程序配置文件

    JSON字符串转对象_微信小程序配置文件微信就是最大的坑!!!!!之前做的小程序,前台都是默认参数(返回json之类的),使用也都正常然而,今天发现的问题也是愁死个人,返回的json就是字符串,自然取不到里面的数据.小程序的js还有好多函数他不支持,坑.之前都是returnjson_encode($arr);这样子返回数据,代码都是一样,就这次莫名不好使.网上的答案也是千篇一律.最后有两篇文章都提到了一个问题,一试,果然有效.转jso…

    2022年9月28日
    5

发表回复

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

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