Step 9.3: Add a new class, HelloSWT


Step 9.3: Add a new class, HelloSWT

click to expand

Like most third-party packages, the SWT packages are in a JAR file. SWT is a little different from other packages, though, in that it is not "100% Pure Java," meaning that there is at least one component to the SWT package that is not contained in a JAR file. For SWT, this is a special file that interfaces between the Java classes and the operating system. In Windows, this is a DLL file. In this step, you'll see one way of including this (or any other) DLL in your environment. Later we'll show you a more pervasive way.

q 9.3(a) Make sure the SWT project is selected.

q 9.3(b) Right-click in the Package Explorer and select File/New/Class.

click to expand
Figure 9.11: Creating a new class using New/Class.

q 9.3(c) Make sure the Source Folder is SWT.

q 9.3(d) Leave Package blank.

q 9.3(e) Leave Enclosing type unchecked.

q 9.3(f) Enter HelloSWT in the Name field.

q 9.3(g) Make sure public is checked, abstract and final unchecked.

q 9.3(h) Leave Superclass as java.lang.Object, Interfaces blank.

q 9.3(i) Make sure public static void main(String[] args) is checked.

q 9.3(j) Leave the other two unchecked.

q 9.3(k) Select Finish.

click to expand
Figure 9.12: Setting the fields properly for a new class.

This will create a class HelloSWT in the default package (because you left Package blank) in project SWT. It will be a public class, neither abstract nor final. The class has no superclass (except for the implied superclass Object) and implements no interfaces. Finally, the IDE has been instructed to create a standard "main" method, but no other methods . That being the case, we will see the result as in Figure 9.13.

click to expand
Figure 9.13: The result of the addition of the new class HelloSWT.



Eclipse
Eclipse: Step by Step (Step-by-Step series)
ISBN: 1583470441
EAN: 2147483647
Year: 2003
Pages: 90
Authors: Joe Pluta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net