Your first JFace application : JFace Introduction « SWT « Java Tutorial






import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;

public class ApplicationWindowJFrace {
  public static void main(String[] args) {
    new MainWindow();
  }
}

class MainWindow extends ApplicationWindow {
  public MainWindow() {
    super(null);
    // Don't return from open() until window closes
    setBlockOnOpen(true);

    // Open the main window
    open();

    // Dispose the display
    Display.getCurrent().dispose();

  }

  protected Control createContents(Composite parent) {
    // Create a Hello, World label
    Label label = new Label(parent, SWT.CENTER);
    label.setText("www.java2s.com");
    return label;
  }

}
  1. ApplicationWindow is JFace's abstraction of Shell.
  2. ApplicationWindow class represents a window in an application.
  3. ApplicationWindow contains support for a menu bar, a toolbar, a coolbar, and a status line.

If it has a parent Shell:

ApplicationWindow(Shell parentShell)

If parentShell is null, the ApplicationWindow represents a top-level window. Otherwise, it's a child of parentShell.









17.115.JFace Introduction
17.115.1.Required JFace JAR files:
17.115.2.Your first JFace application