Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:

Rich clients with the SWT and JFace

Build a GUI application using Java and the Eclipse GUI APIs

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone

Page 3 of 5

Figure 2. SWT packages

At the time of this writing, SWT has been ported to the following platforms (operating systems and windowing systems): aix/motif, hpux/motif, linux/gtk, linux/motif, linux/qt, macos/carbon, qnx/photon, solaris/motif, win32/win32, and win32-ce/win32. SWT is also a very lightweight API, which makes it ideal for embedded devices as demonstrated by the Windows CE port.

JFace

From the previous description of SWT, you should have gotten the impression that it provides a raw widget set. But what about all of the advancements implemented in Swing, such as strong MVC microarchitectures for complex, often-used widgets such as Trees and Tables? To provide a more advanced, model-driven interaction with SWT, the Eclipse team created the JFace toolkit. JFace is a higher-level user interface toolkit that uses the raw SWT widgets to provide model-driven widgets, and to some extent some functionality that isn't available in the Swing libraries, such as advanced editors, dialog boxes, and wizards. JFace covers many areas of UI development that developers encounter over and over, and it provides a clean way to accomplish those tasks. JFace depends on SWT, but it doesn't hide SWT widgets. For example, JFace viewers, which are model-based content adapters for SWT widgets, provide methods to access the underlying SWT widgets. This duality provides developers with the separation and ability to choose between model-driven UI development and raw widget manipulation. Figure 3 shows a graphical overview of the JFace API.

Figure 3. JFace packages

Some of the packages shown in Figure 3 and a short explanation of their functionality are shown here:

  • Window: The org.eclipse.jface.window package provides window creation and management facilities. Of particular interest is the ApplicationWindow class, which provides a higher-level application window and encapsulates the SWT event loop.
  • Viewers: The org.eclipse.jface.viewers package provides a framework of viewers such as TreeViewer and TableViewer, which are model-driven components that make use of SWT widgets and adapt content of a model to the widget.
  • Dialogs: The org.eclipse.jface.dialogs package provides several commonly used dialog boxes.
  • Actions: The org.eclipse.jface.actions package provides a UI action framework that's similar to Swing's action framework in order to implement shared behavior between two or more user interface components, such as a menu item and toolbar button.
  • Wizards: The org.eclipse.jface.wizard package provides an advanced framework to create wizards (the familiar dialog boxes that automate repetitive and complex tasks).
  • Resource: The org.eclipse.jface.resource package provides support for managing resources, such as SWT fonts and images.
  • Text: The org.eclipse.jface.text package and its subpackages provide a framework for creating, manipulating, displaying, and editing text documents.

SWT primer

The first step you need to take to start building SWT applications is to get the latest SWT release for your platform. If you've installed the Eclipse IDE on your system, then you already have all the necessary JARs and native libraries. If you don't have Eclipse installed, you can obtain SWT as a separate distribution (since release 2.1).

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources