diff --git a/Main.java b/Main.java index 1a68b2dd0a36d3447eed91dc217b0ec3bb12c172..2c9e0644f54a26476d8fd1df71de782a09ba9024 100644 --- a/Main.java +++ b/Main.java @@ -1,5 +1,46 @@ -class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } +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(); + } } \ No newline at end of file