欢迎来到代码驿站!

JAVA代码

当前位置:首页 > 软件编程 > JAVA代码

SWT(JFace)Group(分组显示)

时间:2020-10-15 23:16:31|栏目: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();
}
}

上一篇:图文详解Java环境变量配置方法

栏    目:JAVA代码

下一篇:浅谈java运用注解实现对类中的方法检测的工具

本文标题:SWT(JFace)Group(分组显示)

本文地址:http://www.codeinn.net/misctech/11782.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有