Java Reference
In-Depth Information
Microsoft Windows. If you have ever written an X Window or Microsoft
Windows application in straight C (without a GUI framework library or class
library), you have written a main() function that contains an event loop . SWT
actually puts simple method calls around this core message queue event loop.
We'll cover the details of this in the next section where we introduce the
Display and Shell classes.
17.2.6
SWT consists mainly of classes that represent controls—such as buttons, text
areas, scrollbars, and so on—and layout managers which are much like layout
managers in Swing. But there are two other classes: Display , which models
the interface between your Java application and the underlying windowing
system, and Shell , which effectively represents a single window.
The application in Example 17.1 is a parallel to the simple Swing program
in the last chapter (Example 16.1).
This simple program, like its parallel in the Swing chapter, is deceptive.
Sure, this is a lot of code to say “Hello, world” but it is because what we are
setting up here is an event-driven program that must respond to any valid
user input.
“Hello, world” SWT Style
17.2.6.1
One advantage of Swing that we haven't pointed out up to now is that it is part
of every Java runtime (well, not gcj ; more on that later), so you have all the
classes on your classpath without any special setup. Not so with SWT. The
exact procedure for setting up to run an SWT application depends on what
development environment you are using.
There is an excellent set of directions for running an SWT application
under Eclipse in the SWT FAQ. 8 No matter what your environment is, there
is a basic series of steps:
Setting Up to Run an SWT Application
1. Download the Eclipse SDK.
2. Install it.
8. http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/platform-swt-home/
faq.html?rev=1.83content-type=text/html#standalone . Note that this link is to
the current revision in CVS as of this writing. You should take a look at the parent page to see
if there is a newer revision.
Search WWH ::




Custom Search