SWT(JFace)Group(分组显示)

演示代码:


代码如下:

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

(0)

相关推荐

  • SWT(JFace)Group(分组显示)

    演示代码: 复制代码 代码如下: 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

  • SWT(JFace) FTP客户端实现

    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布局

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

  • spring @Validated 注解开发中使用group分组校验的实现

    之前知道spring支持JSR校验,在自己定义的bean中加入@NotNull,@NotBlank,@Length等之类的校验用于处理前台传递过来的request请求,避免在写多余的代码去处理. 但是随着业务的复杂度增加,对于校验的制定也越来越有要求,这个时候就需要引入分组group的概念,在自定义注解@Validated中 定义了一个Class[]数组用来分组.这样我们就可以引入分组校验的概念,首先根据需要的分组新建自己的接口. 然后在需要校验的bean上加入分组: 最后根据需要,在Contr

  • SpringBoot集成swagger-ui以及swagger分组显示操作

    大家好,这篇文章展示下如何在springboot项目中集成swagger-ui.有人说,这都是老生常谈,网上的例子数不胜数.确实swagger诞生至今已经很久了,但是在使用过程中我遇到一个问题,下面给大家分享下我的使用心得吧. 1.swagger配置类 第一步,需要在pom中引入相应的配置,这里使用2.7.0的版本.需要注意的是2.7.0和2.8.0的版本在界面风格上差异很大,如果感兴趣,可以试试2.8.0以上的版本,我比较青睐使用2.7.0及以下的版本,因为界面比较清爽. 第一步 引入pom

  • SWT(JFace) Wizard(Eclipse插件编程必备)

    演示代码如下: HotelReservation.java 复制代码 代码如下: package swt_jface.demo12; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.window.ApplicationWindow; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.SWT; import org.eclips

  • SWT(JFace) 打印功能

    演示代码如下: 复制代码 代码如下: package swt_jface.demo11; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.printing.PrintDialog; import org.eclipse.swt.printing.Printer; import org.eclipse.swt.printing.PrinterData; import org.eclipse.swt.widgets.Display

  • SWT JFace Bookmark 制作

    代码如下: BookmarkOrganizer.java 复制代码 代码如下: package swt_jface.demo11; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import ja

  • SWT JFace 小制作 文本阅读器

    代码如下: 复制代码 代码如下: package swt_jface.demo11; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; import org.eclipse.core.runtime.IProgressMonit

  • SWT(JFace)小制作 FileBrowser文件浏览

    代码如下: 复制代码 代码如下: package swt_jface.demo6; import java.io.File; import java.util.Date; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import o

随机推荐