JFace is a UI toolkit with classes for handling many common UI programming tasks. JFace is window-system-independent in both its API and implementation, and is designed to work with SWT without hiding it. JFace includes the usual UI toolkit components of image and font registries, text, dialog, preference and wizard frameworks, and progress reporting for long running operations. Two of its more interesting features are actions and viewers. The action mechanism allows user commands to be defined independently from their exact whereabouts in the UI. Viewers are model based adapters for certain SWT widgets, simplifying the presentation of application data structured as lists, tables or trees.
New in Eclipse 3.2 is the JFace data binding framework. Data binding allows linking UI elements and models so that users can edit or view the data in the model. The framework makes it easy to connect data sources to widgets such as text fields, combos, tables and trees, for viewing and editing. Using it relieves developers from writing and registering listeners with widgets and model objects.
- Platform UI home page
- Plug-in Developer's Guide: JFace
- Workbench and JFace Articles
- JFace code snippets
Using JFace outside the Eclipse platform
JFace can be used in standalone SWT+JFace apps, without requiring the Eclipse Runtime or other parts of the Eclipse Platform. This was made easier to do in 3.2, with the only prerequisites for JFace being reduced to SWT, the new org.eclipse.equinox.common plug-in, and org.eclipse.core.commands plug-in.
For more details, see Bug 49497.
In 3.3 an optional dependency on the org.osgi.framework package was added which is defined in the org.eclipse.osgi. If this plug-in is absent JFace will continue to function but without the benefit of internationalization support for it's images.
Setting Up an Eclipse Project to use SWT and JFace
This section contains detailed instructions for creating an Eclipse project for developing a stand-alone Java program that uses SWT and JFace. This will be broken down into three steps, as follows:
- Identify the required external JAR files for JFace.
- Create an Eclipse project (called org.eclipse.swt) that will have all of the required SWT and JFace JAR files on it's build path and configure the Order and Export tab of the Build Path to export these files. This project will supply the required JAR files to any other Eclipse project that needs them.
- On any new Java projects that need to use SWT or JFace, simply add the org.eclipse.swt project as a required project on the Projects tab of the Build Path.
Detailed instructions for each of these steps are outlined below.
Identify the Required External JAR Files for SWT and JFace
For Eclipse version 126.96.36.199, the required JAR files for JFace are as follows (where <version info> is the specific version information):
org.eclipse.core.commands_<version info>.jar org.eclipse.equinox.commands_<version info>.jar org.eclipse.jface_<version info>.jar org.eclipse.osgi_<version info>.jar org.eclipse.ui.workbench_<version info>.jar
The file org.eclipse.ui.workbench_<version info>.jar is not required to run the standard JFace classes. However, since it adds a number of very useful Dialogs (such as ListDialog, ListSelectionDialog, and others), it is included here as well.
You can find the JFace dependencies for any Eclipse version if you have the Plug-in Development Environment, which includes the Plug-ins and Plug-in Dependencies views. To do this:
- Select Window/Show View/PDE/Plug-ins. (Note, if you don't have a PDE view folder, it means you don't have the Plug-in Developer Environment plug-in in your Eclipse installation.)
- Select the org.eclipse.jface plug-in from the list.
- Right-click and select Open Dependencies. This will open the Plug-in Dependencies view. An example of this view for Eclipse version 188.8.131.52 is shown below.
- Press the Set Flat Layout button to see a simple flat list of the required plug-ins, as shown below.
Each plug-in on the list corresponds to a JAR file in the plugins directory for your Eclipse installation. If the list for your Eclipse version is different than the list above, make a note of it and modify the remaining instructions accordingly. At this point, we have the list of JAR files that we need.