Open main menu

CDOT Wiki β

HelloJFace Application Using Eclipse

Revision as of 10:23, 28 February 2011 by Selmys (talk | contribs) (Created page with '== HelloJFace Application Using Eclipse == This example demonstrates how to build a simple Hello JFace example GUI using Eclipse. This example is similar to the previous (HelloS…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

HelloJFace Application Using Eclipse

This example demonstrates how to build a simple Hello JFace example GUI using Eclipse.

This example is similar to the previous (HelloSWT) Java project.

Start by creating a Java project and including this code:

package ca.on.senecac.scs;

import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class HelloJFace extends ApplicationWindow {
   
    public HelloJFace()
      {
        super(null);
      }

      protected Control createContents(Composite parent)
      {
        Button b = new Button(parent, SWT.PUSH);
        b.setText("Hello JFace!");
        return b;
      }

      public static void main(String[] args) {
          HelloJFace w = new HelloJFace();
          w.setBlockOnOpen(true);
          w.open();
          Display.getCurrent().dispose();
      }

}

To run this application you'll have to set up some libraries in the build path.

When you're donw it should look something like this:


Then when you run the application, you should get this:


Congratulations, you're done!