SWT(JFace)Group(分组显示)_Java编程

演示代码:

复制代码 代码如下:

package swt_jface.demo9;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class GroupExamples {

Display display = new Display();
Shell shell = new Shell(display);
public GroupExamples() {

Group group0 = new Group(shell, SWT.NULL);
group0.setLayout(new FillLayout());
Label label = new Label(group0, SWT.NULL);
label.setAlignment(SWT.CENTER);
label.setText("a group without title.");

Group group1 = new Group(shell, SWT.NULL);
group1.setText("SWT.NULL");

Group group2 = new Group(shell, SWT.SHADOW_ETCHED_IN);
group2.setText("SWT.SHADOW_ETCHED_IN");
Group group3 = new Group(shell, SWT.SHADOW_ETCHED_OUT);
group3.setText("SWT.SHADOW_ETCHED_OUT");

Group group4 = new Group(shell, SWT.SHADOW_IN);
group4.setText("SWT.SHADOW_IN");

Group group5 = new Group(shell, SWT.SHADOW_OUT);
group5.setText("SWT.SHADOW_OUT");

Group[] groups = new Group[]{group0, group1, group2, group3, group4, group5};

for(int i=0; i<groups.length; i++) {
groups[i].setBounds(10, 10 + i * 50, 300, 40);
}
shell.pack();
shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
public static void main(String[] args) {
new GroupExamples();
}
}
package swt_jface.demo9;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class GroupExamples {

    Display display = new Display();
    Shell shell = new Shell(display);
    public GroupExamples() {

        Group group0 = new Group(shell, SWT.NULL);
        group0.setLayout(new FillLayout());
        Label label = new Label(group0, SWT.NULL);
        label.setAlignment(SWT.CENTER);
        label.setText("a group without title.");

        Group group1 = new Group(shell, SWT.NULL);
        group1.setText("SWT.NULL");

        Group group2 = new Group(shell, SWT.SHADOW_ETCHED_IN);
        group2.setText("SWT.SHADOW_ETCHED_IN");    
        Group group3 = new Group(shell, SWT.SHADOW_ETCHED_OUT);
        group3.setText("SWT.SHADOW_ETCHED_OUT");        

        Group group4 = new Group(shell, SWT.SHADOW_IN);
        group4.setText("SWT.SHADOW_IN");    

        Group group5 = new Group(shell, SWT.SHADOW_OUT);
        group5.setText("SWT.SHADOW_OUT");

        Group[] groups = new Group[]{group0, group1, group2, group3, group4, group5};

        for(int i=0; i<groups.length; i++) {
            groups[i].setBounds(10, 10 + i * 50, 300, 40);
        }
        shell.pack();
        shell.open();

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
    }
    public static void main(String[] args) {
        new GroupExamples();
    }
}

再看一个例子:

复制代码 代码如下:

package swt_jface.demo9;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class BugReport {

Display display = new Display();
Shell shell = new Shell(display);
public BugReport() {

shell.setLayout(new GridLayout(1, true));
shell.setImage(new Image(display, "C:/icons/bug.gif"));
shell.setText("Bug report page");

Group groupBug = new Group(shell, SWT.NULL);
groupBug.setText("Bug details");
groupBug.setLayout(new GridLayout(2, false));
groupBug.setLayoutData(new GridData(GridData.FILL_BOTH));

new Label(groupBug, SWT.NULL).setText("Priority");
Combo combo = new Combo(groupBug, SWT.BORDER);
combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

new Label(groupBug, SWT.NULL).setText("Details");
Text text = new Text(groupBug, SWT.BORDER | SWT.MULTI);
text.setLayoutData(new GridData(GridData.FILL_BOTH));

Group groupProxy = new Group(shell, SWT.NULL);
groupProxy.setText("Connection setting");
groupProxy.setLayout(new GridLayout(2, false));
groupProxy.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

new Label(groupProxy, SWT.NULL).setText("Proxy host");
Text textHost = new Text(groupProxy, SWT.SINGLE | SWT.BORDER);
textHost.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(groupProxy, SWT.NULL).setText("Proxy port");
Text textPort = new Text(groupProxy, SWT.SINGLE | SWT.BORDER);
textPort.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

Button button = new Button(shell, SWT.PUSH);
button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
//button.setAlignment(SWT.CENTER);
button.setText("Submit bug report");
shell.pack();
shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
public static void main(String[] args) {
new BugReport();
}
}

时间: 2024-10-15 02:57:19

SWT(JFace)Group(分组显示)_Java编程的相关文章

SWT(JFace) FTP客户端实现_Java编程

Jar包一览: org.eclipse.jface_3.4.2.M20090107-0800.jar org.eclipse.swt.win32.win32.x86_3.4.1.v3452b.jar org.eclipse.core.commands_3.4.0.I20080509-2000.jar org.eclipse.core.runtime_3.4.0.v20080512.jar org.eclipse.equinox.common_3.4.0.v20080421-2006.jar or

SWT(JFace)体验之GridLayout布局_Java编程

GridLayout布局 GridLayout 布局的功能非常强大,也是笔者常用的一种布局方式.GridLayout是网格式布局,它把父组件分成一个表格,默认情况下每个子组件占据一个单元格的空间,每个子组件按添加到父组件的顺序排列在表格中.GridLayout提供了很多的属性,可以灵活设置网格的信息.另外,GridLayout 布局提供了GridData类,子组件可以设置相应的GridData,例如 "dogPhoto.setLayoutData(gridData)",GridData

SWT(JFace)体验之ViewForm的使用_Java编程

代码如下: 复制代码 代码如下: package swt_jface.demo9; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ViewForm; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.s

SWT/Jface核心编程 一书目录

编程 <<SWT/Jface核心编程>>                          目录                     第一部分 从 Swing 到SWT 第1章        SWT/Jface 简介 1.1 最初的Swing工具包 1.2 什么是SWT/Jface 1.3 Swing 与 SWT 1.4 SWT/Jface 的包 1.5 如何安装 SWT Designer    1.5.1 下载    1.5.2 安装 SWT Designer    1.5.

SWT/JFace核心编程目录(未完待续)

编程 <<SWT/Jface核心编程>>                          目录                     第一部分 从 Swing 到SWT 第1章        SWT/Jface 简介 1.1 最初的Swing工具包 1.2 什么是SWT/Jface 1.3 Swing 与 SWT 1.4 SWT/Jface 的包 1.5 如何安装 SWT Designer    1.5.1 下载    1.5.2 安装 SWT Designer    1.5.

SWT/JFace开发入门指南之搭建开发环境

写在前面的话 终于决定提起笔来写一篇关于swt和JFace编程的文章.在开始之前,我想先介绍一下你能够从将要出现的这一系列文章里得到什么,以及更重要的,你不能得到什么.我们的时间是如此之重要,以至于我们很难容忍把它浪费在自己不关心的事情上. 因为我刚开始写,所以到底这些文章会分成几次发布出来,也很难讲.但是我心里大体有这样一个提纲.也就是说,我打算介绍以下方面的内容: ·设定swt以及JFace的开发环境 ·swt的一些简单部件(widget)介绍 ·JFace的一些入门性介绍 ·swt和JFa

如何在Eclipse 3.6.2中安装swt/JFace

原文http://blog.csdn.net/nkliming/article/details/7790288 我之前一直想安装过swt,但是eclipse一直有问题,后来听说用java写的界面太难看了,所以一直也没再装过.最近做eclipse插件开发,没办法,又要再装swt了.按照下面的步骤,我成功完成了安装: 1.Eclipse:help->Install New Software ,右边有个add选项,界面如下: Name可以不输,location输入:http://dl.google.c

重新想象 Windows 8 Store Apps (12) - 控件之 GridView 特性: 拖动项, 项尺寸可变, 分组显示

原文:重新想象 Windows 8 Store Apps (12) - 控件之 GridView 特性: 拖动项, 项尺寸可变, 分组显示 [源码下载] 重新想象 Windows 8 Store Apps (12) - 控件之 GridView 特性: 拖动项, 项尺寸可变, 分组显示 作者:webabcd 介绍重新想象 Windows 8 Store Apps 之 GridView 拖动项 - 在 GridView 内拖动 item 以对 item 排序, 拖动 item 到 GridView

求大神们指点-安省会分组显示该省的信息怎么做啊?

问题描述 安省会分组显示该省的信息怎么做啊? 解决方案 用sql里面的group by.自己google下. 解决方案二: 用dict字典等,省份做字典的key