extends WizardPage (getNextPage()) : WizardPage « org.eclipse.jface.wizard « Java by API






extends WizardPage (getNextPage())

import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class MainClass {
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    WizardDialog dlg = new WizardDialog(shell, new SurveyWizard());
    dlg.open();
    display.dispose();
  }
}

class SurveyWizard extends Wizard {
  public SurveyWizard() {
    // Add the pages
    addPage(new ComplaintsPage());
    addPage(new MoreInformationPage());
    addPage(new ThanksPage());
  }
  public boolean performFinish() {
    return true;
  }
}

class ThanksPage extends WizardPage {
  public ThanksPage() {
    super("Thanks");
  }
  public void createControl(Composite parent) {
    Label label = new Label(parent, SWT.CENTER);
    label.setText("Thanks!");
    setControl(label);
  }
}

class MoreInformationPage extends WizardPage {
  public MoreInformationPage() {
    super("More Info");
  }

  public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    new Label(composite, SWT.LEFT).setText("Please enter your complaints");
    Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
    text.setLayoutData(new GridData(GridData.FILL_BOTH));

    setControl(composite);
  }
}

class ComplaintsPage extends WizardPage {
  private Button yes;

  private Button no;

  public ComplaintsPage() {
    super("Complaints");
  }
  public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(2, true));

    new Label(composite, SWT.LEFT).setText("Do you have complaints?");
    Composite yesNo = new Composite(composite, SWT.NONE);
    yesNo.setLayout(new FillLayout(SWT.VERTICAL));

    yes = new Button(yesNo, SWT.RADIO);
    yes.setText("Yes");

    no = new Button(yesNo, SWT.RADIO);
    no.setText("No");

    setControl(composite);
  }

  public IWizardPage getNextPage() {
    if (yes.getSelection()) {
      return super.getNextPage();
    }
    return getWizard().getPage("Thanks");
  }
}
           
       








Related examples in the same category

1.extends WizardPage