Java Reference
In-Depth Information
Example 17.1 A simple SWT application
import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
/**
* @author mschwarz
*
* Sample SWT "Hello, world" application
*/
public class SWTHelloWorld {
public static void main(String[] args) {
Display disp = new Display();
Shell window = new Shell(disp);
window.setLayout(new RowLayout());
Label label = new Label(window, SWT.NONE);
label.setText("Hello, world.");
window.setSize(320,160);
window.open();
while (!window.isDisposed()) {
if (!disp.readAndDispatch()) {
disp.sleep();
}
}
disp.dispose();
}
}
3. Extract the SWT JAR files.
4. Extract the SWT JNI files.
5. Configure your development environment.
Let's go over these in a bit more detail.
SWT was developed as a GUI library for the Eclipse project. It is distribut-
ed as part of Eclipse. There is no official standalone SWT package. The right
way to obtain SWT is to download and (at least temporarily) install the Eclipse
SDK. See Section 10.4 for details.
Search WWH ::




Custom Search