13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

382Chapter 17Other Ways: Alternatives to SwingExample 17.1 A simple SWT applicati<strong>on</strong>import org.eclipse.swt.*;import org.eclipse.swt.layout.*;import org.eclipse.swt.widgets.*;/*** @author mschwarz** Sample SWT "Hello, world" applicati<strong>on</strong>*/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. C<strong>on</strong>figure your development envir<strong>on</strong>ment.Let’s go over these in a bit more detail.SWT was developed as a GUI library for the Eclipse project. It is distributedas part of Eclipse. There is no official standal<strong>on</strong>e SWT package. The rightway to obtain SWT is to download and (at least temporarily) install the EclipseSDK. See Secti<strong>on</strong> 10.4 for details.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!