Difference between revisions of "HelloJFace Application Using Eclipse"

From CDOT Wiki
Jump to: navigation, search
(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…')
 
(HelloJFace Application Using Eclipse)
 
Line 37: Line 37:
 
To run this application you'll have to set up some libraries in the build path.
 
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:
+
When you're done it should look something like this:
 
[[Image:jface-1.png|left|thumb]]<br style="clear:left;" />
 
[[Image:jface-1.png|left|thumb]]<br style="clear:left;" />
 
Then when you run the application, you should get this:
 
Then when you run the application, you should get this:
 
[[Image:jface-2.png|left|thumb]]<br style="clear:left;" />
 
[[Image:jface-2.png|left|thumb]]<br style="clear:left;" />
 
Congratulations, you're done!
 
Congratulations, you're done!

Latest revision as of 11:25, 28 February 2011

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 done it should look something like this:

Jface-1.png

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

Jface-2.png

Congratulations, you're done!