www.developer.com/java/other/article.php/3330861
|
By Koray Guclu March 25, 2004 5. Running SWT Applications Outside of EclipseTo run the application without using Eclipse, the swt.jar library must be in your classpath, and the java.library.path enviroment variable must be set properly. Depending on the host platform, the appropriate native library file must be available. For the Windows platform, you can do the following to make the native library configuration for your application:
javac classpath c:\swt\swt.jar HelloWorld.java
6. SWT PackagesThe SWT consists of the following main packages. Definitions of the packages are taken from the Eclipse API documentation. You can find the API documentation on the Eclipse Web site. 7. DialogsDialog implementations are native. That is to say, dialogs, like widgets, are platform components. Dialogs in SWT are derived from the Dialog abstract class. A dialog is not a widget but it can contain widgets.
Figure 2. Dialog class hierharcy. There are different types of dialogs available. Some dialogs can have specific properties. A a dialog can be used as shown in Source 2.
Each dialog's open() method returns different types. For instance, the MessageBox dialog returns int from the open() metod. Therefore, one must write different conditions to handle the return value for each dialog. ColorDialog shows a color selection pallet. It returns an RGB object from return method. DirectoryDialog enables you to select a directory. It returns A String from THE open() method. The returning value is the selected directory. It is also possible to set additional filters to filter the directories. The Font dialog enables a user to select a font from all available fonts in the system. It returns a FontData object from the open() method. FileDialog enables a user to select a file. Additionally, you can set an extension filter, path filter, and filename filters. This dialog has the styles shown in Table 1:
PrintDialog enables a user to select a printer before starting a print job. It returns a Printer Data object from the open() method. The MessageBox dialog is used to give feedback to the user. You can combine different styles by the | operation as shown in Source 3.
The resulting message box of the above example is shown in Figure 3.
Figure 3. MessageBox dialog. Available button constants are listed below. A combination of different buttons can be made by using the | operation. The SWT framework builds the dialog depending on the style bits. The button constants are: SWT.ABORT, SWT.OK, SWT.CANCEL, SWT.RETRY, SWT.IGNORE, SWT.YES, and SWT.NO. Table 2 shows a list of available icons to be used by dialogs.
| |||||||||||||||||||||||||||
| Go to page: Prev 1 2 3 4 5 6 Next |