# JFace Dialog Wizard

Subclasses of the JFace Dialog class can be created using the JFace Dialog wizard. The wizard can be selected from the drop down Designer wizard menu or from the Eclipse New wizard.

To use the wizard, select the project source folder and package to contain the class. Then enter the class name and hit the Finish button.

The wizard generates the following code.

    import org.eclipse.jface.dialogs.Dialog;
    import org.eclipse.jface.dialogs.IDialogConstants;
    import org.eclipse.swt.graphics.Point;
    import org.eclipse.swt.widgets.Composite;
    import org.eclipse.swt.widgets.Control;
    import org.eclipse.swt.widgets.Shell;

    public class JFaceDialogTest extends Dialog {
    	public JFaceDialogTest(Shell parentShell) {
    		super(parentShell);
    	}

    	protected Control createDialogArea(Composite parent) {
    		Composite container = (Composite) super.createDialogArea(parent);
    		return container;
    	}

    	protected void createButtonsForButtonBar(Composite parent) {
    		createButton(parent, IDialogConstants.OK_ID,
    			IDialogConstants.OK_LABEL, true);
    		createButton(parent, IDialogConstants.CANCEL_ID,
    			IDialogConstants.CANCEL_LABEL, false);
    	}

    	protected Point getInitialSize() {
    		return new Point(500, 375);
    	}
    }

When editing JFace Dialogs, any widget may be added to the main content area. In the button bar area, only Dialog Buttons may be added (on the JFace Viewers palette).

When adding a new dialog button, you can select an ID from a predefined list by clicking on the "…​" button in the ID property. The Standard ID’s shown are all of the standard button ID’s defined in the IDialogConstants interface.

You can create news IDs by clicking on the New button. ID names need to be valid Java identifiers (preferably uppercase). The ID values are then defined as offsets from IDialogConstants.ID_CLIENT.

Any new IDs are then listed in the Custom ID’s list.