Skip to main content
Jump to: navigation, search

Difference between revisions of "FAQ Can I create an application that doesn't have views or editors?"

(No difference)

Latest revision as of 16:50, 14 March 2006

When you create an RCP application using a workbench advisor, you are still constrained to using the standard Eclipse UI constructs of views, editors, and perspectives. If you have very different UI requirements but still want to use the plug-in infrastructure, you can always create an application built on only SWT and JFace. This has been possible since the first release of Eclipse as SWT and JFace have no other dependencies outside the base runtime plug-in. JFace provides a basic ApplicationWindow with optional menus, toolbar, and status line.

Configuration of a JFace application works through subclassing rather than plugging in an advisor. Your application needs to subclass the JFace class called ApplicationWindow and override the various methods that are used to customize the appearance and behavior of the window. The following is a simple JFace application window from the FAQ examples plug-in. As with other applications, you begin by creating a class that implements IPlatformRunnable:

   public class JFaceApp implements IPlatformRunnable {
      public Object run(Object args) throws Exception {
         Display display = new Display();
         JFaceAppWindow window = new JFaceAppWindow();;
         Shell shell = window.getShell();
         while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
         return EXIT_OK;

JFaceAppWindow is a subclass of the framework class ApplicationWindow. The subclass creates a simple window with a menu bar, a status line, and a single button inside the main window that is used to exit the application (Figure 16.2).

    <img src=../images/jface_app.png>

    Figure 16.2   Simple JFace application

Complete source for the class can be found in the FAQ Examples plug-in, but here is the basic structure:

   public class JFaceAppWindow extends ApplicationWindow {
      public JFaceAppWindow() {
      protected void configureShell(Shell shell) {
         shell.setText("Simple JFace Application");

The subclass also needs to override the createContents method to create the SWT widgets that will appear in the window&#146;s main content area. Override createMenuManager to populate the window&#146;s menus, createToolBarManager to populate the toolbar, and so on. If you browse through the ApplicationWindow class, you will see that many other hook methods allow your application to customize the appearance of the top-level window.

See Also:


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.

Back to the top