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

📄 wizard.java

📁 FMJ(freedom media for java)是java视频开发的新选择
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package net.sf.fmj.ui.wizard;import java.awt.BorderLayout;import java.awt.CardLayout;import java.awt.Component;import java.awt.Dialog;import java.awt.Frame;import java.awt.Insets;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.beans.PropertyChangeEvent;import java.beans.PropertyChangeListener;import javax.swing.Box;import javax.swing.BoxLayout;import javax.swing.Icon;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JPanel;import javax.swing.JSeparator;import javax.swing.border.EmptyBorder;/** *  * Adapted Robert Eckstein's sample at http://java.sun.com/developer/technicalArticles/GUI/swing/wizard/ *  * This class implements a basic wizard dialog, where the programmer can * insert one or more Components to act as panels. These panels can be navigated * through arbitrarily using the 'Next' or 'Back' buttons, or the dialog itself * can be closed using the 'Cancel' button. Note that even though the dialog * uses a CardLayout manager, the order of the panels is not linear. Each panel * determines at runtime what its next and previous panel will be. */public class Wizard extends WindowAdapter implements PropertyChangeListener {    /**     * Indicates that the 'Finish' button was pressed to close the dialog.     */        public static final int FINISH_RETURN_CODE = 0;    /**     * Indicates that the 'Cancel' button was pressed to close the dialog, or     * the user pressed the close box in the corner of the window.     */        public static final int CANCEL_RETURN_CODE = 1;    /**     * Indicates that the dialog closed due to an internal error.     */        public static final int ERROR_RETURN_CODE = 2;            /**     * The String-based action command for the 'Next' button.     */        public static final String NEXT_BUTTON_ACTION_COMMAND = "NextButtonActionCommand";    /**     * The String-based action command for the 'Back' button.     */        public static final String BACK_BUTTON_ACTION_COMMAND = "BackButtonActionCommand";    /**     * The String-based action command for the 'Cancel' button.     */        public static final String CANCEL_BUTTON_ACTION_COMMAND = "CancelButtonActionCommand";            // The i18n text used for the buttons. Loaded from a property resource file.            static String BACK_TEXT = "< Back";    static String NEXT_TEXT = "Next >";    static String FINISH_TEXT = "Finish";    static String CANCEL_TEXT = "Cancel";    // The image icons used for the buttons. Filenames are loaded from a property resource file.    //    static Icon BACK_ICON;//    static Icon NEXT_ICON;//    static Icon FINISH_ICON;//    static Icon CANCEL_ICON;            private WizardModel wizardModel;    private WizardController wizardController;    private JDialog wizardDialog;            private JPanel cardPanel;    private CardLayout cardLayout;                private JButton backButton;    private JButton nextButton;    private JButton cancelButton;        private int returnCode;            /**     * Default constructor. This method creates a new WizardModel object and passes it     * into the overloaded constructor.     */    //    public Wizard() {//        this((Frame)null);//    }        /**     * This method accepts a java.awt.Dialog object as the javax.swing.JDialog's     * parent.     * @param owner The java.awt.Dialog object that is the owner of this dialog.     */        public Wizard(Dialog owner) {        wizardModel = new WizardModel();        wizardDialog = new JDialog(owner);                 initComponents();    }     /**     * This method accepts a java.awt.Frame object as the javax.swing.JDialog's     * parent.     * @param owner The java.awt.Frame object that is the owner of the javax.swing.JDialog.     */        public Wizard(Frame owner) {        wizardModel = new WizardModel();        wizardDialog = new JDialog(owner);                 initComponents();    }        /**     * Returns an instance of the JDialog that this class created. This is useful in     * the event that you want to change any of the JDialog parameters manually.     * @return The JDialog instance that this class created.     */        public JDialog getDialog() {        return wizardDialog;    }        /**     * Returns the owner of the generated javax.swing.JDialog.     * @return The owner (java.awt.Frame or java.awt.Dialog) of the javax.swing.JDialog generated     * by this class.     */        public Component getOwner() {        return wizardDialog.getOwner();    }        /**     * Sets the title of the generated javax.swing.JDialog.     * @param s The title of the dialog.     */        public void setTitle(String s) {        wizardDialog.setTitle(s);    }        /**     * Returns the current title of the generated dialog.     * @return The String-based title of the generated dialog.     */        public String getTitle() {        return wizardDialog.getTitle();    }        /**     * Sets the modality of the generated javax.swing.JDialog.     * @param b the modality of the dialog     */        public void setModal(boolean b) {        wizardDialog.setModal(b);    }        /**     * Returns the modality of the dialog.     * @return A boolean indicating whether or not the generated javax.swing.JDialog is modal.     */        public boolean isModal() {        return wizardDialog.isModal();    }        /**     * Convienence method that displays a modal wizard dialog and blocks until the dialog     * has completed.     * @return Indicates how the dialog was closed. Compare this value against the RETURN_CODE     * constants at the beginning of the class.     */        public int showModalDialog() {                wizardDialog.setModal(true);        wizardDialog.pack();        wizardDialog.setLocationRelativeTo(wizardDialog.getOwner());        wizardDialog.setVisible(true);                return returnCode;    }        /**     * Returns the current model of the wizard dialog.     * @return A WizardModel instance, which serves as the model for the wizard dialog.     */        public WizardModel getModel() {        return wizardModel;    }        /**     * Add a Component as a panel for the wizard dialog by registering its     * WizardPanelDescriptor object. Each panel is identified by a unique Object-based     * identifier (often a String), which can be used by the setCurrentPanel()     * method to display the panel at runtime.     * @param id An Object-based identifier used to identify the WizardPanelDescriptor object.     * @param panel The WizardPanelDescriptor object which contains helpful information about the panel.     */        public void registerWizardPanel(Object id, WizardPanelDescriptor panel) {                //  Add the incoming panel to our JPanel display that is managed by        //  the CardLayout layout manager.                cardPanel.add(panel.getPanelComponent(), id);                //  Set a callback to the current wizard.                panel.setWizard(this);                //  Place a reference to it in the model.                 wizardModel.registerPanel(id, panel);

⌨️ 快捷键说明

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