提交 7d7967f3 编写于 作者: 幼稚园小盆友's avatar 幼稚园小盆友

生产代码片段

上级 00470cde
class Main { import org.eclipse.swt.SWT;
public static void main(String[] args) { import org.eclipse.swt.layout.FillLayout;
System.out.println("Hello world!"); 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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册