Main.java 1.6 KB
Newer Older
幼稚园小盆友's avatar
幼稚园小盆友 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;

public class SWTWindowExample {
    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setText("SWT Window Example");
        shell.setSize(400, 300);

        // 创建Composite容器
        Composite composite = new Composite(shell, SWT.NONE);
        composite.setLayout(new FillLayout(SWT.VERTICAL));

        // 创建左侧部分,显示BMIDE的lov值
        Table table = new Table(composite, SWT.BORDER | SWT.V_SCROLL);
        for (int i = 0; i < 20; i++) {
            TableItem item = new TableItem(table, SWT.NONE);
            item.setText("Item " + i);
        }

        // 创建右侧部分,带单选按钮
        Group group = new Group(composite, SWT.NONE);
        group.setText("Options");
        group.setLayout(new FillLayout(SWT.VERTICAL));
        Button button1 = new Button(group, SWT.RADIO);
        button1.setText("Option 1");
        Button button2 = new Button(group, SWT.RADIO);
        button2.setText("Option 2");

        // 设置滚动条
        ScrolledComposite scrolledComposite = new ScrolledComposite(shell, SWT.V_SCROLL);
        scrolledComposite.setContent(composite);
        scrolledComposite.setExpandVertical(true);
        scrolledComposite.setExpandHorizontal(true);

        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
    }
6
UPDATE  
64104061f23fda247c679fa8 已提交
46
}