public class Swt {
public Swt() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Hello world");
shell.setBounds(0, 700, 1000, 200);
//窗口始终最前
OS.SetWindowPos(shell.handle, OS.HWND_TOPMOST, 500, 111, 1000,200,
SWT.NULL);
Text helloText = new Text(shell, SWT.CENTER);
helloText.setText("Hello,World!");
helloText.pack();
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
public static void main(String[] args) {
Swt t = new Swt();
}
}