⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wizard.java

📁 一个OR Mapping 工具
💻 JAVA
字号:
package org.dbgen.gui;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.*;/** * Wizard is used to drive a series of WizardCards in order to gather * certain information from the user in an interactive basis.  It is * implemented as a JDialog containing a working area using CardLayout * and a row of button at the button showing Cancel, Previous, Next, * and Finish. */public class Wizard extends javax.swing.JDialog implements ActionListener {  org.dbgen.gui.WizardCard[] fieldCards = null;  protected transient java.beans.PropertyChangeSupport propertyChange = new java.beans.PropertyChangeSupport(this);  javax.swing.JPanel fieldWorkArea = null;  javax.swing.JButton fieldCancelButton = null;  javax.swing.JButton fieldFinishButton = null;  javax.swing.JButton fieldPreviousButton = null;  javax.swing.JButton fieldNextButton = null;  int fieldCurrentCard = 0;  boolean fieldDone = false;  JLabel fieldMessage = null;  WizardAction fieldAction = null;  /**   * Wizard constructor comment.   */  public Wizard() {    super();  }  /**   * Wizard constructor comment.   * @param arg1 java.awt.Frame   */  public Wizard(java.awt.Frame arg1) {    super(arg1);  }  /**   * Wizard constructor comment.   * @param arg1 java.awt.Frame   * @param arg2 java.lang.String   */  public Wizard(java.awt.Frame arg1, String arg2) {    super(arg1, arg2);  }  /**   * Wizard constructor comment.   * @param arg1 java.awt.Frame   * @param arg2 java.lang.String   * @param arg3 boolean   */  public Wizard(java.awt.Frame arg1, String arg2, boolean arg3) {    super(arg1, arg2, arg3);  }  /**   * Wizard constructor comment.   * @param arg1 java.awt.Frame   * @param arg2 boolean   */  public Wizard(java.awt.Frame arg1, boolean arg2) {    super(arg1, arg2);  }  /**   * This method was created by a SmartGuide.   * @param event ActionEvent   */  public void actionPerformed(ActionEvent event) {    String cmd = event.getActionCommand();    if (cmd.equals("Previous"))    {      showPage(getCurrentCard() - 1);    }    else if (cmd.equals("Next"))    {      if (getCurrentCardObject().proceedNext())        showPage(getCurrentCard() + 1);    }    else if (cmd.equals("Cancel"))    {      dispose();    }    else if (cmd.equals("Finish"))    {      if (getAction() != null)      {        getAction().actionPerformed(this);      }      setVisible(false);    }    return;  }  /**   * The addPropertyChangeListener method was generated to support the propertyChange field.   */  public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener listener) {    propertyChange.addPropertyChangeListener(listener);  }  /**   * This method was created by a SmartGuide.   * @return org.dbgen.gui.Wizard   * @param card org.dbgen.gui.WizardCard   */  public static Wizard findWizard(WizardCard card) {    Component comp = (Component) card;    while (comp != null && !(comp instanceof Wizard))      comp = comp.getParent();    return (Wizard) comp;  }  /**   * The firePropertyChange method was generated to support the propertyChange field.   */  public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {    propertyChange.firePropertyChange(propertyName, oldValue, newValue);  }  /**   * Gets the action property (org.dbgen.gui.WizardAction) value.   * @return The action property value.   * @see #setAction   */  public WizardAction getAction() {    /* Returns the action property value. */    return fieldAction;  }  /**   * Gets the cancelButton property (javax.swing.JButton) value.   * @return The cancelButton property value.   */  public javax.swing.JButton getCancelButton() {    /* Returns the cancelButton property value. */    if (fieldCancelButton == null) {      try {        fieldCancelButton = new javax.swing.JButton("Cancel");      } catch (Throwable exception) {        System.err.println("Exception creating cancelButton property.");      }    };    return fieldCancelButton;  }  /**   * This method was created by a SmartGuide.   * @return java.lang.String   * @param page int   */  protected String getCardName(int page) {    return ((Component) getCards()[page]).toString();  }  /**   * Gets the cards property (org.dbgen.gui.WizardCard[]) value.   * @return The cards property value.   * @see #setCards   */  public org.dbgen.gui.WizardCard[] getCards() {    /* Returns the cards property value. */    return fieldCards;  }  /**   * Gets the currentCard property (int) value.   * @return The currentCard property value.   * @see #setCurrentCard   */  public int getCurrentCard() {    /* Returns the currentCard property value. */    return fieldCurrentCard;  }  /**   * This method was created by a SmartGuide.   * @return org.dbgen.gui.WizardCard   */  protected WizardCard getCurrentCardObject() {    return getCards()[getCurrentCard()];  }  /**   * Gets the done property (boolean) value.   * @return The done property value.   * @see #setDone   */  public boolean getDone() {    /* Returns the done property value. */    return fieldDone;  }  /**   * Gets the finishButton property (javax.swing.JButton) value.   * @return The finishButton property value.   */  public javax.swing.JButton getFinishButton() {    /* Returns the finishButton property value. */    if (fieldFinishButton == null) {      try {        fieldFinishButton = new javax.swing.JButton("Finish");      } catch (Throwable exception) {        System.err.println("Exception creating finishButton property.");      }    };    return fieldFinishButton;  }  /**   * Gets the message property (javax.swing.JLabel) value.   * @return The message property value.   */  public JLabel getMessage() {    /* Returns the message property value. */    if (fieldMessage == null) {      try {        fieldMessage = new JLabel("Welcome To Wizard Expert");      } catch (Throwable exception) {        System.err.println("Exception creating message property.");      }    };    return fieldMessage;  }  /**   * Gets the nextButton property (javax.swing.JButton) value.   * @return The nextButton property value.   */  public javax.swing.JButton getNextButton() {    /* Returns the nextButton property value. */    if (fieldNextButton == null) {      try {        fieldNextButton = new javax.swing.JButton("Next >");        fieldNextButton.setActionCommand("Next");      } catch (Throwable exception) {        System.err.println("Exception creating nextButton property.");      }    };    return fieldNextButton;  }  /**   * This method was created by a SmartGuide.   * @return org.dbgen.gui.WizardCard   */  public WizardCard getNextCard() {    int curr = getCurrentCard();    return curr < (getCards().length-1) ? getCards()[curr+1] : null;  }  /**   * Gets the previousButton property (javax.swing.JButton) value.   * @return The previousButton property value.   */  public javax.swing.JButton getPreviousButton() {    /* Returns the previousButton property value. */    if (fieldPreviousButton == null) {      try {        fieldPreviousButton = new javax.swing.JButton("< Back");        fieldPreviousButton.setActionCommand("Previous");      } catch (Throwable exception) {        System.err.println("Exception creating previousButton property.");      }    };    return fieldPreviousButton;  }  /**   * This method was created by a SmartGuide.   * @return org.dbgen.gui.WizardCard   */  public WizardCard getPreviousCard() {    int curr = getCurrentCard();    return curr > 0 ? getCards()[curr-1] : null;  }  /**   * Gets the workArea property (javax.swing.JPanel) value.   * @return The workArea property value.   */  public javax.swing.JPanel getWorkArea() {    /* Returns the workArea property value. */    if (fieldWorkArea == null) {      try {        fieldWorkArea = new javax.swing.JPanel();      } catch (Throwable exception) {        System.err.println("Exception creating workArea property.");      }    };    return fieldWorkArea;  }  /**   * This method was created by a SmartGuide.   */  public void initialize() {    Container container = getContentPane();    BevelBorder bevelBorder = new BevelBorder(BevelBorder.RAISED);    EmptyBorder emptyBorder1 = new EmptyBorder(5, 5, 5, 5);    EmptyBorder emptyBorder2 = new EmptyBorder(15, 15, 15, 15);    CompoundBorder compBorder = new CompoundBorder(emptyBorder1, new CompoundBorder(bevelBorder, emptyBorder2));    JPanel workArea = getWorkArea();    workArea.setBorder(compBorder);    workArea.setLayout(new CardLayout());    for (int i = 0; i < getCards().length; i++) {      WizardCard c = getCards()[i];      workArea.add(c.getCardName(), (Component)c);    }    Box buttonRow = new Box(BoxLayout.X_AXIS);    buttonRow.add(getCancelButton());    buttonRow.add(Box.createHorizontalGlue());    buttonRow.add(getPreviousButton());    buttonRow.add(getNextButton());    buttonRow.add(Box.createHorizontalStrut(10));    buttonRow.add(getFinishButton());    JPanel bottom = new JPanel(new BorderLayout(0, 5));    JLabel label = getMessage();    label.setBorder(new CompoundBorder(new EtchedBorder(), emptyBorder1));    bottom.setBorder(new EmptyBorder(5, 5, 5, 5));    bottom.add(BorderLayout.SOUTH, label);    bottom.add(BorderLayout.NORTH, buttonRow);    container.setLayout(new BorderLayout(5, 5));    container.add(BorderLayout.CENTER, getWorkArea());    container.add(BorderLayout.SOUTH, bottom);    getCancelButton().addActionListener(this);    getPreviousButton().addActionListener(this);    getNextButton().addActionListener(this);    getFinishButton().addActionListener(this);    showPage(0);    return;  }  /**   * The removePropertyChangeListener method was generated to support the propertyChange field.   */  public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener listener) {    propertyChange.removePropertyChangeListener(listener);  }  /**   * Sets the action property (org.dbgen.gui.WizardAction) value.   * @param action The new value for the property.   * @see #getAction   */  public void setAction(WizardAction action) {    fieldAction = action;    return;  }  /**   * Sets the cards property (org.dbgen.gui.WizardCard[]) value.   * @param cards The new value for the property.   * @see #getCards   */  public void setCards(org.dbgen.gui.WizardCard[] cards) {    /* Get the old property value for fire property change event. */    org.dbgen.gui.WizardCard[] oldValue = fieldCards;    /* Set the cards property (attribute) to the new value. */    fieldCards = cards;    /* Fire (signal/notify) the cards property change event. */    firePropertyChange("cards", oldValue, cards);    /* Remove all components and create new ones based on the cards. */    initialize();    return;  }  /**   * Sets the currentCard property (int) value.   * @param currentCard The new value for the property.   * @see #getCurrentCard   */  public void setCurrentCard(int currentCard) {    /* Get the old property value for fire property change event. */    int oldValue = fieldCurrentCard;    /* Set the currentCard property (attribute) to the new value. */    fieldCurrentCard = currentCard;    /* Fire (signal/notify) the currentCard property change event. */    firePropertyChange("currentCard", new Integer(oldValue), new Integer(currentCard));    return;  }  /**   * Sets the done property (boolean) value.   * @param done The new value for the property.   * @see #getDone   */  public void setDone(boolean done) {    /* Get the old property value for fire property change event. */    boolean oldValue = fieldDone;    /* Set the done property (attribute) to the new value. */    fieldDone = done;    /* Fire (signal/notify) the done property change event. */    firePropertyChange("done", null, new Boolean(done));    return;  }  /**   * Performs the setMessage method.   * @param message java.lang.String   */  public void setMessage(String message) {    /* Perform the setMessage method. */    getMessage().setText(message);    return;  }  /**   * This method was created by a SmartGuide.   * @param page int   */  public void showPage(int page) {    if (page < 0 || page >= getCards().length) {      System.err.println("Bug: Cannot show page " + page);      return;    }    setCurrentCard(page);    CardLayout cardLayout = (CardLayout) getWorkArea().getLayout();    String pageName = getCurrentCardObject().getCardName();    cardLayout.show(getWorkArea(), pageName);    getCurrentCardObject().cardShown(this);    // Disable previous button if it's the first page.    getPreviousButton().setEnabled(page > 0);    updateSensitivities();    repaint();    return;  }  /**   * This method was created by a SmartGuide.   */  public void updateSensitivities() {    getNextButton().setEnabled(getCurrentCardObject().enableNextButton());    getFinishButton().setEnabled(getCurrentCardObject().enableFinishButton());    return;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -