|
Hello Again
Listing 1. This simple Hello World application shows the basic layout of an SWT application. package com.develop;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class HelloWorld
{
public static void main(String[] args)
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Hello World Application");
shell.setBounds(20, 20, 300, 100);
Label label = new Label(shell, SWT.CENTER);
label.setText("Hello World");
label.setBounds(shell.getClientArea());
shell.layout();
shell.open();
while(!shell.isDisposed())
if(!display.readAndDispatch())
display.sleep();
display.dispose();
}
}
|