diff options
| author | Paul Buetow <paul@buetow.org> | 2009-03-04 18:25:32 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2009-03-04 18:25:32 +0000 |
| commit | 6deeb57d62c238d3f152cdef1d782b441c73797a (patch) | |
| tree | f12600b080dbcdfed825f2a79f58c2d45fda93de /libs/FLib/JWizard/org | |
| parent | 9129838d208c0df7293e5b757661125545cd6df8 (diff) | |
jcalendar lib
Diffstat (limited to 'libs/FLib/JWizard/org')
| -rw-r--r-- | libs/FLib/JWizard/org/freixas/jwizard/JWizardDialog.java | 1536 | ||||
| -rw-r--r-- | libs/FLib/JWizard/org/freixas/jwizard/JWizardPanel.java | 622 |
2 files changed, 1079 insertions, 1079 deletions
diff --git a/libs/FLib/JWizard/org/freixas/jwizard/JWizardDialog.java b/libs/FLib/JWizard/org/freixas/jwizard/JWizardDialog.java index 355a9d4..8f4236d 100644 --- a/libs/FLib/JWizard/org/freixas/jwizard/JWizardDialog.java +++ b/libs/FLib/JWizard/org/freixas/jwizard/JWizardDialog.java @@ -107,18 +107,18 @@ import java.util.ResourceBundle; // All Rights Reserved. public class JWizardDialog - extends JDialog + extends JDialog { //********************************************************************** // Private Constants //********************************************************************** -private static final int BACK_BUTTON = 0; -private static final int NEXT_BUTTON = 1; -private static final int FINISH_BUTTON = 2; -private static final int CANCEL_BUTTON = 3; -private static final int HELP_BUTTON = 4; + private static final int BACK_BUTTON = 0; + private static final int NEXT_BUTTON = 1; + private static final int FINISH_BUTTON = 2; + private static final int CANCEL_BUTTON = 3; + private static final int HELP_BUTTON = 4; //********************************************************************** // Private Members @@ -127,544 +127,544 @@ private static final int HELP_BUTTON = 4; // The label which holds the image to display on the left side of the // wizard. -private JPanel logoPanel; -private JLabel logoLabel; + private JPanel logoPanel; + private JLabel logoLabel; // The panel to which JWizardPanel's are added. -private JPanel workArea; + private JPanel workArea; // The layout for the work area. -private CardLayout cardLayout; + private CardLayout cardLayout; // The current JWizardPanel -private JWizardPanel currentWizard = null; -private int currentStep = -1; -private int lastStep = -1; -private int panelCount = 0; + private JWizardPanel currentWizard = null; + private int currentStep = -1; + private int lastStep = -1; + private int panelCount = 0; // The button panel and buttons -private JPanel buttonPanel; -private JPanel buttons; -private JButton buttonBack; -private JButton buttonNext; -private JButton buttonFinish; -private JButton buttonCancel; -private JButton buttonHelp; + private JPanel buttonPanel; + private JPanel buttons; + private JButton buttonBack; + private JButton buttonNext; + private JButton buttonFinish; + private JButton buttonCancel; + private JButton buttonHelp; // True if the finish button should be enabled all the time -private boolean enableEarlyFinish = false; + private boolean enableEarlyFinish = false; // True if the cancel button is enabled on the final step -private boolean enableCancelAtEnd = true; + private boolean enableCancelAtEnd = true; // True if the dialog should be centered on display -private boolean isCentered = true; + private boolean isCentered = true; // True if the wizard finished -private boolean isFinished = false; + private boolean isFinished = false; // The resource bundle -private static ResourceBundle bundle = - ResourceBundle.getBundle("org.freixas.jwizard.Bundle"); + private static ResourceBundle bundle = + ResourceBundle.getBundle("org.freixas.jwizard.Bundle"); //********************************************************************** // Constructors //********************************************************************** -/** - * Creates a non-modal JWizardDialog without a title and without a - * specified Frame owner. A shared, hidden frame will be set as the - * owner of the dialog. - * <p> - * This constructor sets the component's locale property to the value - * returned by JComponent.getDefaultLocale(). - * - * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. - */ - -public -JWizardDialog() + /** + * Creates a non-modal JWizardDialog without a title and without a + * specified Frame owner. A shared, hidden frame will be set as the + * owner of the dialog. + * <p> + * This constructor sets the component's locale property to the value + * returned by JComponent.getDefaultLocale(). + * + * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. + */ + + public + JWizardDialog() throws HeadlessException -{ - super(); - init(); -} - -/** - * Creates a non-modal JWizardDialog without a title with the - * specified Frame as its owner. If owner is null, a shared, hidden - * frame will be set as the owner of the dialog. - * <p> - * This constructor sets the component's locale property to the value - * returned by JComponent.getDefaultLocale(). - * - * @param owner The Frame owning the dialog. - * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. - */ - -public -JWizardDialog( - Frame owner) - throws HeadlessException -{ - super(owner); - init(); -} - -/** - * Creates a modal or non-modal JWizardDialog without a title and with - * the specified owner Frame. If owner is null, a shared, hidden - * frame will be set as the owner of the dialog. - * - * This constructor sets the component's locale property to the value - * returned by JComponent.getDefaultLocale(). - * - * @param owner The Frame owning the dialog. - * @param modal True for a modal dialog, false for one that allows - * others windows to be active at the same time. - * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. - */ + { + super(); + init(); + } -public -JWizardDialog( - Frame owner, - boolean modal) + /** + * Creates a non-modal JWizardDialog without a title with the + * specified Frame as its owner. If owner is null, a shared, hidden + * frame will be set as the owner of the dialog. + * <p> + * This constructor sets the component's locale property to the value + * returned by JComponent.getDefaultLocale(). + * + * @param owner The Frame owning the dialog. + * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. + */ + + public + JWizardDialog( + Frame owner) throws HeadlessException -{ - super(owner, modal); - init(); -} - -/** - * Creates a non-modal JWizardDialog with the specified title and with - * the specified owner frame. If owner is null, a shared, hidden - * frame will be set as the owner of the dialog. - * <p> - * This constructor sets the component's locale property to the value - * returned by JComponent.getDefaultLocale(). - * - * @param owner The Frame owning the dialog. - * @param title The String to display in the dialog's title bar. - * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. - */ + { + super(owner); + init(); + } -public -JWizardDialog( - Frame owner, - String title) + /** + * Creates a modal or non-modal JWizardDialog without a title and with + * the specified owner Frame. If owner is null, a shared, hidden + * frame will be set as the owner of the dialog. + * + * This constructor sets the component's locale property to the value + * returned by JComponent.getDefaultLocale(). + * + * @param owner The Frame owning the dialog. + * @param modal True for a modal dialog, false for one that allows + * others windows to be active at the same time. + * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. + */ + + public + JWizardDialog( + Frame owner, + boolean modal) throws HeadlessException -{ - super(owner, title); - init(); -} - -/** - * Creates a modal or non-modal JWizardDialog with the specified title - * and the specified owner Frame. If owner is null, a shared, hidden - * frame will be set as the owner of this dialog. All constructors - * defer to this one. - * <p> - * NOTE: Any popup components (JComboBox, JPopupMenu, JMenuBar) - * created within a modal dialog will be forced to be lightweight. - * <p> - * This constructor sets the component's locale property to the value - * returned by JComponent.getDefaultLocale(). - * - * @param owner The Frame owning the dialog. - * @param title The String to display in the dialog's title bar. - * @param modal True for a modal dialog, false for one that allows - * others windows to be active at the same time. - * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. - */ - -public -JWizardDialog( - Frame owner, - String title, - boolean modal) - throws HeadlessException -{ - super(owner, title, modal); - init(); -} - -/** - * Creates a modal or non-modal JWizardDialog with the specified - * title, owner Frame, and GraphicsConfiguration. - * <p> - * NOTE: Any popup components (JComboBox, JPopupMenu, JMenuBar) - * created within a modal dialog will be forced to be lightweight. - * <p> - * This constructor sets the component's locale property to the value - * returned by JComponent.getDefaultLocale. - * - * @param owner The Frame owning the dialog. - * @param title The String to display in the dialog's title bar. - * @param modal True for a modal dialog, false for one that allows - * others windows to be active at the same time. - * @param gc The GraphicsConfiguration of the target screen device. If - * gc is null, the same GraphicsConfiguration as the owning Frame - * is used. - * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. - */ - -public -JWizardDialog( - Frame owner, - String title, - boolean modal, - GraphicsConfiguration gc) - throws HeadlessException -{ - super(owner, title, modal, gc); - init(); -} - -/** - * Creates a non-modal JWizardDialog without a title with the - * specified Dialog as its owner. If owner is null, a shared, hidden - * frame will be set as the owner of the dialog. - * <p> - * This constructor sets the component's locale property to the value - * returned by JComponent.getDefaultLocale(). - * - * @param owner The Dialog owning the dialog. - * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. - */ - -public -JWizardDialog( - Dialog owner) - throws HeadlessException -{ - super(owner); - init(); -} + { + super(owner, modal); + init(); + } -/** - * Creates a modal or non-modal JWizardDialog without a title and with - * the specified owner Dialog. If owner is null, a shared, hidden - * frame will be set as the owner of the dialog. - * - * This constructor sets the component's locale property to the value - * returned by JComponent.getDefaultLocale(). - * - * @param owner The Dialog owning the dialog. - * @param modal True for a modal dialog, false for one that allows - * others windows to be active at the same time. - * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. - */ + /** + * Creates a non-modal JWizardDialog with the specified title and with + * the specified owner frame. If owner is null, a shared, hidden + * frame will be set as the owner of the dialog. + * <p> + * This constructor sets the component's locale property to the value + * returned by JComponent.getDefaultLocale(). + * + * @param owner The Frame owning the dialog. + * @param title The String to display in the dialog's title bar. + * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. + */ + + public + JWizardDialog( + Frame owner, + String title) + throws HeadlessException + { + super(owner, title); + init(); + } -public -JWizardDialog( - Dialog owner, - boolean modal) + /** + * Creates a modal or non-modal JWizardDialog with the specified title + * and the specified owner Frame. If owner is null, a shared, hidden + * frame will be set as the owner of this dialog. All constructors + * defer to this one. + * <p> + * NOTE: Any popup components (JComboBox, JPopupMenu, JMenuBar) + * created within a modal dialog will be forced to be lightweight. + * <p> + * This constructor sets the component's locale property to the value + * returned by JComponent.getDefaultLocale(). + * + * @param owner The Frame owning the dialog. + * @param title The String to display in the dialog's title bar. + * @param modal True for a modal dialog, false for one that allows + * others windows to be active at the same time. + * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. + */ + + public + JWizardDialog( + Frame owner, + String title, + boolean modal) throws HeadlessException -{ - super(owner, modal); - init(); -} + { + super(owner, title, modal); + init(); + } -/** - * Creates a non-modal JWizardDialog with the specified title and with - * the specified owner frame. If owner is null, a shared, hidden - * frame will be set as the owner of the dialog. - * <p> - * This constructor sets the component's locale property to the value - * returned by JComponent.getDefaultLocale(). - * - * @param owner The Dialog owning the dialog. - * @param title The String to display in the dialog's title bar. - * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. - */ + /** + * Creates a modal or non-modal JWizardDialog with the specified + * title, owner Frame, and GraphicsConfiguration. + * <p> + * NOTE: Any popup components (JComboBox, JPopupMenu, JMenuBar) + * created within a modal dialog will be forced to be lightweight. + * <p> + * This constructor sets the component's locale property to the value + * returned by JComponent.getDefaultLocale. + * + * @param owner The Frame owning the dialog. + * @param title The String to display in the dialog's title bar. + * @param modal True for a modal dialog, false for one that allows + * others windows to be active at the same time. + * @param gc The GraphicsConfiguration of the target screen device. If + * gc is null, the same GraphicsConfiguration as the owning Frame + * is used. + * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. + */ + + public + JWizardDialog( + Frame owner, + String title, + boolean modal, + GraphicsConfiguration gc) + throws HeadlessException + { + super(owner, title, modal, gc); + init(); + } -public -JWizardDialog( - Dialog owner, - String title) + /** + * Creates a non-modal JWizardDialog without a title with the + * specified Dialog as its owner. If owner is null, a shared, hidden + * frame will be set as the owner of the dialog. + * <p> + * This constructor sets the component's locale property to the value + * returned by JComponent.getDefaultLocale(). + * + * @param owner The Dialog owning the dialog. + * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. + */ + + public + JWizardDialog( + Dialog owner) throws HeadlessException -{ - super(owner, title); - init(); -} + { + super(owner); + init(); + } -/** - * Creates a modal or non-modal JWizardDialog with the specified title - * and the specified owner Dialog. If owner is null, a shared, hidden - * frame will be set as the owner of this dialog. All constructors - * defer to this one. - * <p> - * NOTE: Any popup components (JComboBox, JPopupMenu, JMenuBar) - * created within a modal dialog will be forced to be lightweight. - * <p> - * This constructor sets the component's locale property to the value - * returned by JComponent.getDefaultLocale(). - * - * @param owner The Dialog owning the dialog. - * @param title The String to display in the dialog's title bar. - * @param modal True for a modal dialog, false for one that allows - * others windows to be active at the same time. - * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. - */ + /** + * Creates a modal or non-modal JWizardDialog without a title and with + * the specified owner Dialog. If owner is null, a shared, hidden + * frame will be set as the owner of the dialog. + * + * This constructor sets the component's locale property to the value + * returned by JComponent.getDefaultLocale(). + * + * @param owner The Dialog owning the dialog. + * @param modal True for a modal dialog, false for one that allows + * others windows to be active at the same time. + * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. + */ + + public + JWizardDialog( + Dialog owner, + boolean modal) + throws HeadlessException + { + super(owner, modal); + init(); + } -public -JWizardDialog( - Dialog owner, - String title, - boolean modal) - throws HeadlessException -{ - super(owner, title, modal); - init(); -} + /** + * Creates a non-modal JWizardDialog with the specified title and with + * the specified owner frame. If owner is null, a shared, hidden + * frame will be set as the owner of the dialog. + * <p> + * This constructor sets the component's locale property to the value + * returned by JComponent.getDefaultLocale(). + * + * @param owner The Dialog owning the dialog. + * @param title The String to display in the dialog's title bar. + * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. + */ + + public + JWizardDialog( + Dialog owner, + String title) + throws HeadlessException + { + super(owner, title); + init(); + } -/** - * Creates a modal or non-modal JWizardDialog with the specified - * title, owner Dialog, and GraphicsConfiguration. - * <p> - * NOTE: Any popup components (JComboBox, JPopupMenu, JMenuBar) - * created within a modal dialog will be forced to be lightweight. - * <p> - * This constructor sets the component's locale property to the value - * returned by JComponent.getDefaultLocale. - * - * @param owner The Dialog owning the dialog. - * @param title The String to display in the dialog's title bar. - * @param modal True for a modal dialog, false for one that allows - * others windows to be active at the same time. - * @param gc The GraphicsConfiguration of the target screen device. If - * gc is null, the same GraphicsConfiguration as the owning Dialog - * is used. - * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. - */ + /** + * Creates a modal or non-modal JWizardDialog with the specified title + * and the specified owner Dialog. If owner is null, a shared, hidden + * frame will be set as the owner of this dialog. All constructors + * defer to this one. + * <p> + * NOTE: Any popup components (JComboBox, JPopupMenu, JMenuBar) + * created within a modal dialog will be forced to be lightweight. + * <p> + * This constructor sets the component's locale property to the value + * returned by JComponent.getDefaultLocale(). + * + * @param owner The Dialog owning the dialog. + * @param title The String to display in the dialog's title bar. + * @param modal True for a modal dialog, false for one that allows + * others windows to be active at the same time. + * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. + */ + + public + JWizardDialog( + Dialog owner, + String title, + boolean modal) + throws HeadlessException + { + super(owner, title, modal); + init(); + } -public -JWizardDialog( - Dialog owner, - String title, - boolean modal, - GraphicsConfiguration gc) - throws HeadlessException -{ - super(owner, title, modal, gc); - init(); -} + /** + * Creates a modal or non-modal JWizardDialog with the specified + * title, owner Dialog, and GraphicsConfiguration. + * <p> + * NOTE: Any popup components (JComboBox, JPopupMenu, JMenuBar) + * created within a modal dialog will be forced to be lightweight. + * <p> + * This constructor sets the component's locale property to the value + * returned by JComponent.getDefaultLocale. + * + * @param owner The Dialog owning the dialog. + * @param title The String to display in the dialog's title bar. + * @param modal True for a modal dialog, false for one that allows + * others windows to be active at the same time. + * @param gc The GraphicsConfiguration of the target screen device. If + * gc is null, the same GraphicsConfiguration as the owning Dialog + * is used. + * @throws HeadlessException If GraphicsEnvironment.isHeadless() returns true. + */ + + public + JWizardDialog( + Dialog owner, + String title, + boolean modal, + GraphicsConfiguration gc) + throws HeadlessException + { + super(owner, title, modal, gc); + init(); + } //********************************************************************** // Public //********************************************************************** -/** - * Add an image which displays on the left side of the wizard. By - * default, no image is displayed. This must be set before the dialog - * is made visible. - * - * @param icon The icon representing the image to display. If null, no - * image is displayed. - */ - -public void -setWizardIcon( - Icon icon) -{ - // If null, remove any existing logo panel - - if (icon == null) { - if (logoPanel != null) { - remove(logoPanel); - logoPanel = null; - logoLabel = null; - } + /** + * Add an image which displays on the left side of the wizard. By + * default, no image is displayed. This must be set before the dialog + * is made visible. + * + * @param icon The icon representing the image to display. If null, no + * image is displayed. + */ + + public void + setWizardIcon( + Icon icon) + { + // If null, remove any existing logo panel + + if (icon == null) { + if (logoPanel != null) { + remove(logoPanel); + logoPanel = null; + logoLabel = null; + } + } + + // If not null, add it or replace an existing label + + else { + if (logoPanel != null) { + remove(logoPanel); + } + logoPanel = new JPanel(new BorderLayout()); + logoLabel = new JLabel(icon); + logoPanel.add(logoLabel, BorderLayout.NORTH); + getContentPane().add(logoPanel, BorderLayout.WEST); + } } - // If not null, add it or replace an existing label - - else { - if (logoPanel != null) { - remove(logoPanel); - } - logoPanel = new JPanel(new BorderLayout()); - logoLabel = new JLabel(icon); - logoPanel.add(logoLabel, BorderLayout.NORTH); - getContentPane().add(logoPanel, BorderLayout.WEST); + /** + * Add a panel representing a step in the wizard. Since removing a + * panel would force a renumbering of the remaining panels and since + * you have flexible sequencing control, there is no matching + * removeWizardPanel() method. + * + * @param panel The JWizardPanel to add + */ + + public void + addWizardPanel( + JWizardPanel panel) + { + if (currentWizard == null) { + currentWizard = panel; + currentStep = 0; + } + workArea.add(panel, Integer.toString(panelCount++)); + panel.setWizardParent(this); } -} - -/** - * Add a panel representing a step in the wizard. Since removing a - * panel would force a renumbering of the remaining panels and since - * you have flexible sequencing control, there is no matching - * removeWizardPanel() method. - * - * @param panel The JWizardPanel to add - */ -public void -addWizardPanel( - JWizardPanel panel) -{ - if (currentWizard == null) { - currentWizard = panel; - currentStep = 0; + /** + * This adds a help button to the wizard. When the button is pressed, + * the help() method is called. + * + * @see #help() + */ + + public void + addHelpButton() + { + if (buttonHelp == null) { + buttonHelp = + new JButton( + new ButtonAction( + "HelpButton", "HelpButtonMnemonic", + "HelpButtonAccelerator", + "images/Help16.gif", + "HelpButtonShort", "HelpButtonLong", HELP_BUTTON)); + buttons.add(buttonHelp); + } } - workArea.add(panel, Integer.toString(panelCount++)); - panel.setWizardParent(this); -} -/** - * This adds a help button to the wizard. When the button is pressed, - * the help() method is called. - * - * @see #help() - */ + /** + * If this method is called, the Finish button is enabled immediately. + * By default, it is enabled only on the last step (any step where the + * next JWizardPanel step is -1). + */ -public void -addHelpButton() -{ - if (buttonHelp == null) { - buttonHelp = - new JButton( - new ButtonAction( - "HelpButton", "HelpButtonMnemonic", - "HelpButtonAccelerator", - "images/Help16.gif", - "HelpButtonShort", "HelpButtonLong", HELP_BUTTON)); - buttons.add(buttonHelp); + public void + setEarlyFinish() + { + enableEarlyFinish = true; } -} -/** - * If this method is called, the Finish button is enabled immediately. - * By default, it is enabled only on the last step (any step where the - * next JWizardPanel step is -1). - */ - -public void -setEarlyFinish() -{ - enableEarlyFinish = true; -} - -/** - * Returns true if the wizard finished (the user pressed the Finish) - * button). Returns false otherwise (either the wizard hasn't finished - * or the user pressed Cancel to exit). - * - * @return True if the wizard finished. - */ - -public boolean -isFinished() -{ - return isFinished; -} - -/** - * If this method is called, the Cancel button is disabled when on the - * last step. If setEarlyFinish() is called, it is still disabled only - * on the last step. - */ + /** + * Returns true if the wizard finished (the user pressed the Finish) + * button). Returns false otherwise (either the wizard hasn't finished + * or the user pressed Cancel to exit). + * + * @return True if the wizard finished. + */ + + public boolean + isFinished() + { + return isFinished; + } -public void -disableCancelAtEnd() -{ - enableCancelAtEnd = false; -} + /** + * If this method is called, the Cancel button is disabled when on the + * last step. If setEarlyFinish() is called, it is still disabled only + * on the last step. + */ -/** - * Don't center the dialog. This method must be called before the - * dialog is made visible. The default behavior is to center the - * dialog over its parent, or on the screen if no parent was given. - */ + public void + disableCancelAtEnd() + { + enableCancelAtEnd = false; + } -public void -disableCentering() -{ - isCentered = false; -} + /** + * Don't center the dialog. This method must be called before the + * dialog is made visible. The default behavior is to center the + * dialog over its parent, or on the screen if no parent was given. + */ -/** - * Returns the current step being displayed by the wizard. Steps start - * at 0. If no step is yet displayed, a -1 is returned. - * - * @return The current step being displayed by the wizard. - */ + public void + disableCentering() + { + isCentered = false; + } -public int -getCurrentStep() -{ - return currentStep; -} + /** + * Returns the current step being displayed by the wizard. Steps start + * at 0. If no step is yet displayed, a -1 is returned. + * + * @return The current step being displayed by the wizard. + */ + + public int + getCurrentStep() + { + return currentStep; + } -/** - * Returns the last step displayed by the wizard. Steps start at 0. If - * there is no previous step yet, -1 is returned. - * - * @return The last step being displayed by the wizard. - */ + /** + * Returns the last step displayed by the wizard. Steps start at 0. If + * there is no previous step yet, -1 is returned. + * + * @return The last step being displayed by the wizard. + */ + + public int + getLastStep() + { + return lastStep; + } -public int -getLastStep() -{ - return lastStep; -} + /** + * @deprecated As of JDK version 1.1, replaced by setVisible(boolean). + */ -/** - * @deprecated As of JDK version 1.1, replaced by setVisible(boolean). - */ + public void + show() + { + goTo(0); -public void -show() -{ - goTo(0); + if (isCentered) { + Dimension screenSize = getToolkit().getScreenSize(); + Dimension parentSize = getParent().getSize(); + Point parentLocation = getParent().getLocation(); - if (isCentered) { - Dimension screenSize = getToolkit().getScreenSize(); - Dimension parentSize = getParent().getSize(); - Point parentLocation = getParent().getLocation(); + // If the parent Frame is invisible, we center the dialog on + // the screen - // If the parent Frame is invisible, we center the dialog on - // the screen + if (!getParent().isVisible()) { + parentSize = getToolkit().getScreenSize(); + parentLocation.setLocation(0, 0); + } - if (!getParent().isVisible()) { - parentSize = getToolkit().getScreenSize(); - parentLocation.setLocation(0, 0); - } + Dimension size = getSize(); - Dimension size = getSize(); + int x = parentLocation.x + (parentSize.width - size.width ) / 2; + int y = parentLocation.y + (parentSize.height - size.height) / 2; - int x = parentLocation.x + (parentSize.width - size.width ) / 2; - int y = parentLocation.y + (parentSize.height - size.height) / 2; + // Make sure the dialog is placed completely on the screen (as + // long as it is smaller than the screen size) - // Make sure the dialog is placed completely on the screen (as - // long as it is smaller than the screen size) + if (size.width < screenSize.width && + x + size.width > screenSize.width) { + x = screenSize.width - size.width; + } + if (size.height < screenSize.height && + y + size.height > screenSize.height) { + y = screenSize.height - size.height; + } + if (x < 0) x = 0; + if (y < 0) y = 0; - if (size.width < screenSize.width && - x + size.width > screenSize.width) { - x = screenSize.width - size.width; - } - if (size.height < screenSize.height && - y + size.height > screenSize.height) { - y = screenSize.height - size.height; - } - if (x < 0) x = 0; - if (y < 0) y = 0; + setBounds(x, y, size.width, size.height); + } - setBounds(x, y, size.width, size.height); + super.show(); } - super.show(); -} - // WizardDialogs are equal if they are the same object, so the default // equals() and hashCode() methods are acceptable. I'm not using the // paramString() method for debugging, so the default is OK @@ -673,261 +673,261 @@ show() // Package Public //********************************************************************** -/** - * Set the sensitivity of each button based on the back and next step - * values. This should be called when changing steps or when the back - * or next button values are changed. - */ - -void -setButtonStates() -{ - int backStep = currentWizard.getBackStep(); - int nextStep = currentWizard.getNextStep(); - - boolean atBegin = backStep < 0 || backStep >= panelCount; - - boolean atEnd = nextStep < 0 || nextStep >= panelCount; - - buttonBack.setEnabled(!atBegin); - buttonNext.setEnabled(!atEnd); - buttonFinish.setEnabled(enableEarlyFinish || atEnd); - buttonCancel.setEnabled(!atEnd || enableCancelAtEnd); - - // Set the default button - - if (buttonNext.isEnabled()) { - getRootPane().setDefaultButton(buttonNext); - } - else if (buttonFinish.isEnabled()) { - getRootPane().setDefaultButton(buttonFinish); + /** + * Set the sensitivity of each button based on the back and next step + * values. This should be called when changing steps or when the back + * or next button values are changed. + */ + + void + setButtonStates() + { + int backStep = currentWizard.getBackStep(); + int nextStep = currentWizard.getNextStep(); + + boolean atBegin = backStep < 0 || backStep >= panelCount; + + boolean atEnd = nextStep < 0 || nextStep >= panelCount; + + buttonBack.setEnabled(!atBegin); + buttonNext.setEnabled(!atEnd); + buttonFinish.setEnabled(enableEarlyFinish || atEnd); + buttonCancel.setEnabled(!atEnd || enableCancelAtEnd); + + // Set the default button + + if (buttonNext.isEnabled()) { + getRootPane().setDefaultButton(buttonNext); + } + else if (buttonFinish.isEnabled()) { + getRootPane().setDefaultButton(buttonFinish); + } + else if (buttonBack.isEnabled()) { + getRootPane().setDefaultButton(buttonBack); + } + else { + getRootPane().setDefaultButton(null); + } } - else if (buttonBack.isEnabled()) { - getRootPane().setDefaultButton(buttonBack); - } - else { - getRootPane().setDefaultButton(null); - } -} -/** - * Display the JWizardPanel with the given step number. This method is - * package public so that JWizardPanel can call it. The - * switchToStep() method may override the step choice. - * </code></pre> - * - * @param step The step number of the JWizardPanel to display. - * @see #switchToStep(int,int) - */ - -void -goTo( - int step) -{ - // Give the user a last chance to change things - - step = switchToStep(currentStep, step); - - // We can't do anything if we're outside the valid range - - if (step < 0 || step >= panelCount) return; - - // Save the current step as the previous step - - lastStep = currentStep; - - currentWizard = (JWizardPanel)workArea.getComponent(step); - currentStep = step; - currentWizard.doMakingVisible(); - cardLayout.show(workArea, Integer.toString(step)); - - // The panel may have just been created or modified in the - // doMakingVisible() method. If so, the CardLayout's original - // guess at the window size may be too small. We increase the size - // if we have to -- but we never decrease the size - - Dimension prefSize = getPreferredSize(); - Dimension curSize = getSize(); - if (prefSize.width > curSize.width || - prefSize.height > curSize.height) { - Dimension newSize = - new Dimension(Math.max(prefSize.width, curSize.width), - Math.max(prefSize.height, curSize.height)); - setSize(newSize); - invalidate(); - validate(); + /** + * Display the JWizardPanel with the given step number. This method is + * package public so that JWizardPanel can call it. The + * switchToStep() method may override the step choice. + * </code></pre> + * + * @param step The step number of the JWizardPanel to display. + * @see #switchToStep(int,int) + */ + + void + goTo( + int step) + { + // Give the user a last chance to change things + + step = switchToStep(currentStep, step); + + // We can't do anything if we're outside the valid range + + if (step < 0 || step >= panelCount) return; + + // Save the current step as the previous step + + lastStep = currentStep; + + currentWizard = (JWizardPanel)workArea.getComponent(step); + currentStep = step; + currentWizard.doMakingVisible(); + cardLayout.show(workArea, Integer.toString(step)); + + // The panel may have just been created or modified in the + // doMakingVisible() method. If so, the CardLayout's original + // guess at the window size may be too small. We increase the size + // if we have to -- but we never decrease the size + + Dimension prefSize = getPreferredSize(); + Dimension curSize = getSize(); + if (prefSize.width > curSize.width || + prefSize.height > curSize.height) { + Dimension newSize = + new Dimension(Math.max(prefSize.width, curSize.width), + Math.max(prefSize.height, curSize.height)); + setSize(newSize); + invalidate(); + validate(); + } + + // Set the button states + + setButtonStates(); } - // Set the button states - - setButtonStates(); -} - //********************************************************************** // Protected //********************************************************************** -/** - * Called when the Back button is pressed. This calls the back() - * method in the current JWizardPanel. - * - * @see JWizardPanel#back() - */ - -protected void -back() -{ - if (currentWizard != null) currentWizard.doBack(); -} - -/** - * Called when the Next button is pressed. This calls the next() - * method in the current JWizardPanel. - * - * @see JWizardPanel#next() - */ - -protected void -next() -{ - if (currentWizard != null) currentWizard.doNext(); -} + /** + * Called when the Back button is pressed. This calls the back() + * method in the current JWizardPanel. + * + * @see JWizardPanel#back() + */ + + protected void + back() + { + if (currentWizard != null) currentWizard.doBack(); + } -/** - * Called when the Finish button is pressed. This calls dispose(). You - * will probably want to override this. - */ + /** + * Called when the Next button is pressed. This calls the next() + * method in the current JWizardPanel. + * + * @see JWizardPanel#next() + */ + + protected void + next() + { + if (currentWizard != null) currentWizard.doNext(); + } -protected void -finish() -{ - isFinished = true; - dispose(); -} + /** + * Called when the Finish button is pressed. This calls dispose(). You + * will probably want to override this. + */ -/** - * Called when the Cancel button is pressed. This calls dispose(). - */ + protected void + finish() + { + isFinished = true; + dispose(); + } -protected void -cancel() -{ - dispose(); -} + /** + * Called when the Cancel button is pressed. This calls dispose(). + */ -/** - * Called when the Help button is pressed. This calls the help() - * method in the current JWizardPanel. If the help text is the same - * for all panels, you will want to override this. - */ + protected void + cancel() + { + dispose(); + } -protected void -help() -{ - if (currentWizard != null) currentWizard.doHelp(); -} + /** + * Called when the Help button is pressed. This calls the help() + * method in the current JWizardPanel. If the help text is the same + * for all panels, you will want to override this. + */ -/** - * This method is called just prior to switching from one step to - * another (after any next() or back() method is called). It receives - * the current and new indices. By default, it returns the new index. - * You can override the method if you need to control sequencing from - * this JWizardDialog class (normally, each step decides what the back - * and next steps should be). - * - * @param currentIndex The index of the current JWizardPanel. - * @param newIndex The index of the JWizardPanel we are about to - * display. - * @return The index of the JWizardPanel to display. - */ + protected void + help() + { + if (currentWizard != null) currentWizard.doHelp(); + } -protected int -switchToStep( - int currentIndex, - int newIndex) -{ - return newIndex; -} + /** + * This method is called just prior to switching from one step to + * another (after any next() or back() method is called). It receives + * the current and new indices. By default, it returns the new index. + * You can override the method if you need to control sequencing from + * this JWizardDialog class (normally, each step decides what the back + * and next steps should be). + * + * @param currentIndex The index of the current JWizardPanel. + * @param newIndex The index of the JWizardPanel we are about to + * display. + * @return The index of the JWizardPanel to display. + */ + + protected int + switchToStep( + int currentIndex, + int newIndex) + { + return newIndex; + } //********************************************************************** // Private //********************************************************************** -/** - * Initialize the JWizardDialog. - */ - -private void -init() -{ - getContentPane().setLayout(new BorderLayout(5, 2)); - - // If the user tries to close the wizard, the result should be the - // same as pressing Cancel - - setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); - - // Window close is the same as cancel. If the cancel button is - // disabled, then a window close does nothing - - addWindowListener( - new WindowAdapter() { - public void windowClosing(WindowEvent e) { - if (buttonCancel.isEnabled()) { - cancel(); - } - } - }); - - // Work area for WizardPanel's - - workArea = new JPanel(); - cardLayout = new CardLayout(); - workArea.setLayout(cardLayout); - - // Buttons - - buttonBack = - new JButton( - new ButtonAction( - "BackButton", "BackButtonMnemonic", "BackButtonAccelerator", - "images/Back16.gif", - "BackButtonShort", "BackButtonLong", BACK_BUTTON)); - buttonNext = - new JButton( - new ButtonAction( - "NextButton", "NextButtonMnemonic", "NextButtonAccelerator", - "images/Forward16.gif", - "NextButtonShort", "NextButtonLong", NEXT_BUTTON)); - buttonFinish = - new JButton( - new ButtonAction( - "FinishButton", "FinishButtonMnemonic", - "FinishButtonAccelerator", - null, - "FinishButtonShort", "FinishButtonLong", FINISH_BUTTON)); - buttonCancel = - new JButton( - new ButtonAction( - "CancelButton", "CancelButtonMnemonic", - "CancelButtonAccelerator", - null, - "CancelButtonShort", "CancelButtonLong", CANCEL_BUTTON)); - - buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - - buttons.add(buttonBack); - buttons.add(buttonNext); - buttons.add(buttonFinish); - buttons.add(buttonCancel); - - buttonPanel = new JPanel(new BorderLayout()); - buttonPanel.add(new JSeparator(), BorderLayout.NORTH); - buttonPanel.add(buttons); - - getContentPane().add(buttonPanel, BorderLayout.SOUTH); - getContentPane().add(workArea); -} + /** + * Initialize the JWizardDialog. + */ + + private void + init() + { + getContentPane().setLayout(new BorderLayout(5, 2)); + + // If the user tries to close the wizard, the result should be the + // same as pressing Cancel + + setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); + + // Window close is the same as cancel. If the cancel button is + // disabled, then a window close does nothing + + addWindowListener( + new WindowAdapter() { + public void windowClosing(WindowEvent e) { + if (buttonCancel.isEnabled()) { + cancel(); + } + } + }); + + // Work area for WizardPanel's + + workArea = new JPanel(); + cardLayout = new CardLayout(); + workArea.setLayout(cardLayout); + + // Buttons + + buttonBack = + new JButton( + new ButtonAction( + "BackButton", "BackButtonMnemonic", "BackButtonAccelerator", + "images/Back16.gif", + "BackButtonShort", "BackButtonLong", BACK_BUTTON)); + buttonNext = + new JButton( + new ButtonAction( + "NextButton", "NextButtonMnemonic", "NextButtonAccelerator", + "images/Forward16.gif", + "NextButtonShort", "NextButtonLong", NEXT_BUTTON)); + buttonFinish = + new JButton( + new ButtonAction( + "FinishButton", "FinishButtonMnemonic", + "FinishButtonAccelerator", + null, + "FinishButtonShort", "FinishButtonLong", FINISH_BUTTON)); + buttonCancel = + new JButton( + new ButtonAction( + "CancelButton", "CancelButtonMnemonic", + "CancelButtonAccelerator", + null, + "CancelButtonShort", "CancelButtonLong", CANCEL_BUTTON)); + + buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + + buttons.add(buttonBack); + buttons.add(buttonNext); + buttons.add(buttonFinish); + buttons.add(buttonCancel); + + buttonPanel = new JPanel(new BorderLayout()); + buttonPanel.add(new JSeparator(), BorderLayout.NORTH); + buttonPanel.add(buttons); + + getContentPane().add(buttonPanel, BorderLayout.SOUTH); + getContentPane().add(workArea); + } //********************************************************************** // Inner Classes @@ -935,78 +935,78 @@ init() // ButtonAction -private class ButtonAction - extends AbstractAction -{ - -ButtonAction( - String name, - String mnemonic, - String accelerator, - String imageName, - String shortDescription, - String longDescription, - int actionId) -{ - if (name != null) { - putValue(Action.NAME, bundle.getString(name)); - } - - if (mnemonic != null) { - putValue(Action.MNEMONIC_KEY, - new Integer(bundle.getString(mnemonic).charAt(0))); - } - - if (accelerator != null) { - putValue( - Action.ACCELERATOR_KEY, - KeyStroke.getKeyStroke(bundle.getString(accelerator))); - } - - URL url = null; - if (imageName != null) { - url = - this.getClass().getResource(imageName); - if (url != null) { - putValue(Action.SMALL_ICON, new ImageIcon(url)); - } - } - - if (shortDescription != null) { - putValue(Action.SHORT_DESCRIPTION, bundle.getString(shortDescription)); - } + private class ButtonAction + extends AbstractAction + { + + ButtonAction( + String name, + String mnemonic, + String accelerator, + String imageName, + String shortDescription, + String longDescription, + int actionId) + { + if (name != null) { + putValue(Action.NAME, bundle.getString(name)); + } + + if (mnemonic != null) { + putValue(Action.MNEMONIC_KEY, + new Integer(bundle.getString(mnemonic).charAt(0))); + } + + if (accelerator != null) { + putValue( + Action.ACCELERATOR_KEY, + KeyStroke.getKeyStroke(bundle.getString(accelerator))); + } + + URL url = null; + if (imageName != null) { + url = + this.getClass().getResource(imageName); + if (url != null) { + putValue(Action.SMALL_ICON, new ImageIcon(url)); + } + } + + if (shortDescription != null) { + putValue(Action.SHORT_DESCRIPTION, bundle.getString(shortDescription)); + } + + if (longDescription != null) { + putValue(Action.LONG_DESCRIPTION, bundle.getString(longDescription)); + } + putValue("buttonAction", new Integer(actionId)); + } + + public void + actionPerformed( + ActionEvent e) + { + Integer value = (Integer)getValue("buttonAction"); + switch (value.intValue()) { + case BACK_BUTTON: + back(); + break; + case NEXT_BUTTON: + next(); + break; + case FINISH_BUTTON: + finish(); + break; + case CANCEL_BUTTON: + cancel(); + break; + case HELP_BUTTON: + help(); + break; + } + } - if (longDescription != null) { - putValue(Action.LONG_DESCRIPTION, bundle.getString(longDescription)); } - putValue("buttonAction", new Integer(actionId)); -} - -public void -actionPerformed( - ActionEvent e) -{ - Integer value = (Integer)getValue("buttonAction"); - switch (value.intValue()) { - case BACK_BUTTON: - back(); - break; - case NEXT_BUTTON: - next(); - break; - case FINISH_BUTTON: - finish(); - break; - case CANCEL_BUTTON: - cancel(); - break; - case HELP_BUTTON: - help(); - break; - } -} - -} //********************************************************************** // End Inner Classes diff --git a/libs/FLib/JWizard/org/freixas/jwizard/JWizardPanel.java b/libs/FLib/JWizard/org/freixas/jwizard/JWizardPanel.java index 840321e..aecc389 100644 --- a/libs/FLib/JWizard/org/freixas/jwizard/JWizardPanel.java +++ b/libs/FLib/JWizard/org/freixas/jwizard/JWizardPanel.java @@ -34,7 +34,7 @@ import javax.swing.*; // All Rights Reserved. public class JWizardPanel - extends JPanel + extends JPanel { //********************************************************************** @@ -43,232 +43,232 @@ public class JWizardPanel // The JWizardDialog parent -JWizardDialog dialogParent; + JWizardDialog dialogParent; // The step title -JPanel titlePanel; -String stepTitle; -JLabel stepTitleLabel; + JPanel titlePanel; + String stepTitle; + JLabel stepTitleLabel; // The content pane -JPanel contentPane; + JPanel contentPane; // The back and next steps -int backStep = -1; -int nextStep = -1; + int backStep = -1; + int nextStep = -1; // Flags the first time the component is added to a window -boolean firstNotify = true; + boolean firstNotify = true; //********************************************************************** // Constructors //********************************************************************** -/** - * Creates a new JWizardPanel with a double buffer and a flow layout. - * The flow layout is assigned to the panel accessed through - * getContentPane(). - */ - -public -JWizardPanel() -{ - super(); - init(new FlowLayout()); -} - -/** - * Create a new buffered JWizardPanel with the specified layout - * manager. The layout is assigned to the panel accessed through - * getContentPane(). - * - * @param layout The LayoutManager for the content pane. - */ - -public -JWizardPanel( - LayoutManager layout) -{ - super(); - init(layout); -} - -/** - * Creates a new JWizardPanel a flow layout and the specified - * buffering strategy. If isDoubleBuffered is true, the JWizardPanel - * will use a double buffer. The layout is assigned to the panel - * accessed through getContentPane(). - * - * @param isDoubleBuffered True for double-buffering, which uses - * additional memory space to achieve fast, flicker-free updates. - */ + /** + * Creates a new JWizardPanel with a double buffer and a flow layout. + * The flow layout is assigned to the panel accessed through + * getContentPane(). + */ + + public + JWizardPanel() + { + super(); + init(new FlowLayout()); + } -public -JWizardPanel( - boolean isDoubleBuffered) -{ - super(isDoubleBuffered); - init(new FlowLayout()); -} + /** + * Create a new buffered JWizardPanel with the specified layout + * manager. The layout is assigned to the panel accessed through + * getContentPane(). + * + * @param layout The LayoutManager for the content pane. + */ + + public + JWizardPanel( + LayoutManager layout) + { + super(); + init(layout); + } -/** - * Creates a new JWizardPanel with the specified layout manager and - * buffering strategy. The layout is assigned to the panel accessed - * through getContentPane(). - * - * @param layout The LayoutManager for the content pane. - * @param isDoubleBuffered True for double-buffering, which uses - * additional memory space to achieve fast, flicker-free updates. - */ + /** + * Creates a new JWizardPanel a flow layout and the specified + * buffering strategy. If isDoubleBuffered is true, the JWizardPanel + * will use a double buffer. The layout is assigned to the panel + * accessed through getContentPane(). + * + * @param isDoubleBuffered True for double-buffering, which uses + * additional memory space to achieve fast, flicker-free updates. + */ + + public + JWizardPanel( + boolean isDoubleBuffered) + { + super(isDoubleBuffered); + init(new FlowLayout()); + } -public -JWizardPanel( - LayoutManager layout, - boolean isDoubleBuffered) -{ - super(isDoubleBuffered); - init(layout); -} + /** + * Creates a new JWizardPanel with the specified layout manager and + * buffering strategy. The layout is assigned to the panel accessed + * through getContentPane(). + * + * @param layout The LayoutManager for the content pane. + * @param isDoubleBuffered True for double-buffering, which uses + * additional memory space to achieve fast, flicker-free updates. + */ + + public + JWizardPanel( + LayoutManager layout, + boolean isDoubleBuffered) + { + super(isDoubleBuffered); + init(layout); + } //********************************************************************** // Public //********************************************************************** -/** - * Set the title to use for this step. Normally this title would be - * unique for each wizards step. - * - * @param stepTitle The title to use for this step. - */ - -public void -setStepTitle( - String stepTitle) -{ - this.stepTitle = stepTitle; - stepTitleLabel.setText(stepTitle); - - stepTitleLabel.invalidate(); - validate(); -} - -/** - * Get the step title to use for this step. - * - * @return The step title to use for this step. - */ - -public String -getStepTitle() -{ - return stepTitle; -} - -/** - * Get a JPanel to use for adding your own components to this - * WizardPanel. Do not add components directly to the JWizardPanel. - * The JPanel uses the layout given in the JWizardPanel constructor. - * - * @return The JPanel to use for adding components for this wizard - * step. - */ - -public JPanel -getContentPane() -{ - return contentPane; -} + /** + * Set the title to use for this step. Normally this title would be + * unique for each wizards step. + * + * @param stepTitle The title to use for this step. + */ + + public void + setStepTitle( + String stepTitle) + { + this.stepTitle = stepTitle; + stepTitleLabel.setText(stepTitle); + + stepTitleLabel.invalidate(); + validate(); + } -/** - * Get the wizard step to go to when the Back button is pressed. - * - * @return The wizard step to go to when the Back button is pressed. - */ + /** + * Get the step title to use for this step. + * + * @return The step title to use for this step. + */ -public int -getBackStep() -{ - return backStep; -} - -/** - * Set the wizard step to go to when the Back button is pressed. This - * should be set in the constructor of the JWizardPanel subclass since - * it determines whether the Back button is enabled or not. - * - * @param backStep The wizard step to go to when the Back button is pressed. - */ + public String + getStepTitle() + { + return stepTitle; + } -public void -setBackStep( - int backStep) -{ - this.backStep = backStep; - JWizardDialog dialog = getWizardParent(); - if (dialog != null) dialog.setButtonStates(); -} + /** + * Get a JPanel to use for adding your own components to this + * WizardPanel. Do not add components directly to the JWizardPanel. + * The JPanel uses the layout given in the JWizardPanel constructor. + * + * @return The JPanel to use for adding components for this wizard + * step. + */ + + public JPanel + getContentPane() + { + return contentPane; + } -/** - * Get the wizard step to go to when the Next button is pressed. - * - * @return The wizard step to go to when the Next button is pressed. - */ + /** + * Get the wizard step to go to when the Back button is pressed. + * + * @return The wizard step to go to when the Back button is pressed. + */ -public int -getNextStep() -{ - return nextStep; -} + public int + getBackStep() + { + return backStep; + } -/** - * Set the wizard step to go to when the Next button is pressed. This - * should be set in the constructor of the JWizardPanel subclass since - * it determines whether the Next and Finish buttons are enabled or not. - * - * @param nextStep The wizard step to go to when the Next button is pressed. - */ + /** + * Set the wizard step to go to when the Back button is pressed. This + * should be set in the constructor of the JWizardPanel subclass since + * it determines whether the Back button is enabled or not. + * + * @param backStep The wizard step to go to when the Back button is pressed. + */ + + public void + setBackStep( + int backStep) + { + this.backStep = backStep; + JWizardDialog dialog = getWizardParent(); + if (dialog != null) dialog.setButtonStates(); + } -public void -setNextStep( - int nextStep) -{ - this.nextStep = nextStep; - JWizardDialog dialog = getWizardParent(); - if (dialog != null) dialog.setButtonStates(); -} + /** + * Get the wizard step to go to when the Next button is pressed. + * + * @return The wizard step to go to when the Next button is pressed. + */ -/** - * Returns the JWizardDialog in which this JWizardPanel resides. This - * is valid only after the panel has been added to the dialog. - * - * @return The JWizardDialog in which this JWizardPanel resides. - */ + public int + getNextStep() + { + return nextStep; + } -public JWizardDialog -getWizardParent() -{ - return dialogParent; -} + /** + * Set the wizard step to go to when the Next button is pressed. This + * should be set in the constructor of the JWizardPanel subclass since + * it determines whether the Next and Finish buttons are enabled or not. + * + * @param nextStep The wizard step to go to when the Next button is pressed. + */ + + public void + setNextStep( + int nextStep) + { + this.nextStep = nextStep; + JWizardDialog dialog = getWizardParent(); + if (dialog != null) dialog.setButtonStates(); + } -/** - * Do not call directly. - */ + /** + * Returns the JWizardDialog in which this JWizardPanel resides. This + * is valid only after the panel has been added to the dialog. + * + * @return The JWizardDialog in which this JWizardPanel resides. + */ + + public JWizardDialog + getWizardParent() + { + return dialogParent; + } -public void -addNotify() -{ - if (firstNotify) { - Font font = stepTitleLabel.getFont(); - font = font.deriveFont(Font.BOLD, font.getSize() * 14 / 10); - stepTitleLabel.setFont(font); - firstNotify = false; + /** + * Do not call directly. + */ + + public void + addNotify() + { + if (firstNotify) { + Font font = stepTitleLabel.getFont(); + font = font.deriveFont(Font.BOLD, font.getSize() * 14 / 10); + stepTitleLabel.setFont(font); + firstNotify = false; + } + super.addNotify(); } - super.addNotify(); -} // WizardPanels are equal if they are the same object, so the default // equals() and hashCode() methods are acceptable. I'm not using the @@ -278,152 +278,152 @@ addNotify() // Package Public //********************************************************************** -/** - * Set the JWizardDialog parent for this JWizardPanel. - * - * @param dialogParent The JWizardPanel parent for this JWizardPanel. - */ - -void -setWizardParent( - JWizardDialog dialogParent) -{ - this.dialogParent = dialogParent; -} - -/** - * Calls makingVisible(). This allows the JWizardDialog to call the - * protected method makingVisible(). - * - * @see #makingVisible() - */ - -void -doMakingVisible() -{ - makingVisible(); -} - -/** - * Calls back(). This allows the JWizardDialog to call the protected - * method back(). - * - * @see #back() - */ - -void -doBack() -{ - back(); -} + /** + * Set the JWizardDialog parent for this JWizardPanel. + * + * @param dialogParent The JWizardPanel parent for this JWizardPanel. + */ + + void + setWizardParent( + JWizardDialog dialogParent) + { + this.dialogParent = dialogParent; + } -/** - * Calls next(). This allows the JWizardDialog to call the protected - * method next(). - * - * @see #next() - */ + /** + * Calls makingVisible(). This allows the JWizardDialog to call the + * protected method makingVisible(). + * + * @see #makingVisible() + */ + + void + doMakingVisible() + { + makingVisible(); + } -void -doNext() -{ - next(); -} + /** + * Calls back(). This allows the JWizardDialog to call the protected + * method back(). + * + * @see #back() + */ + + void + doBack() + { + back(); + } -/** - * Calls help(). This allows the JWizardDialog to call the protected - * method help(). - * - * @see #help() - */ + /** + * Calls next(). This allows the JWizardDialog to call the protected + * method next(). + * + * @see #next() + */ + + void + doNext() + { + next(); + } -void -doHelp() -{ - help(); -} + /** + * Calls help(). This allows the JWizardDialog to call the protected + * method help(). + * + * @see #help() + */ + + void + doHelp() + { + help(); + } //********************************************************************** // Protected //********************************************************************** -/** - * Called just prior to making this panel visible. This is a hook in - * case information in the panel needs to be created dynamically based - * on previous steps. - */ + /** + * Called just prior to making this panel visible. This is a hook in + * case information in the panel needs to be created dynamically based + * on previous steps. + */ -protected void -makingVisible() -{ -} - -/** - * Called when the Back button is pressed. By default this displays - * the wizard step set by setBackStep(). - * - * @see #setBackStep(int) - */ - -protected void -back() -{ - dialogParent.goTo(getBackStep()); -} + protected void + makingVisible() + { + } -/** - * Called when the Next button is pressed. By default this displays - * the wizard step set by setNextStep(). - * - * @see #setNextStep(int) - */ + /** + * Called when the Back button is pressed. By default this displays + * the wizard step set by setBackStep(). + * + * @see #setBackStep(int) + */ + + protected void + back() + { + dialogParent.goTo(getBackStep()); + } -protected void -next() -{ - dialogParent.goTo(getNextStep()); -} + /** + * Called when the Next button is pressed. By default this displays + * the wizard step set by setNextStep(). + * + * @see #setNextStep(int) + */ + + protected void + next() + { + dialogParent.goTo(getNextStep()); + } -/** - * Called when the Help button is pressed. By default this does nothing. - */ + /** + * Called when the Help button is pressed. By default this does nothing. + */ -protected void -help() -{ -} + protected void + help() + { + } //********************************************************************** // Private //********************************************************************** -/** - * Initialize the JWizardPanel. - * - * @param layout The layout to use. - */ + /** + * Initialize the JWizardPanel. + * + * @param layout The layout to use. + */ -private void -init( - LayoutManager layout) -{ - // Set the layout for the JWizardPanel + private void + init( + LayoutManager layout) + { + // Set the layout for the JWizardPanel - setLayout(new BorderLayout(0, 5)); + setLayout(new BorderLayout(0, 5)); - // Set the layout for the content area + // Set the layout for the content area - contentPane = new JPanel(layout); + contentPane = new JPanel(layout); - // Step title + // Step title - titlePanel = new JPanel(new BorderLayout(0, 5)); - titlePanel.add(new JSeparator(), BorderLayout.SOUTH); - stepTitleLabel = new JLabel(" "); - titlePanel.add(stepTitleLabel); + titlePanel = new JPanel(new BorderLayout(0, 5)); + titlePanel.add(new JSeparator(), BorderLayout.SOUTH); + stepTitleLabel = new JLabel(" "); + titlePanel.add(stepTitleLabel); - add(titlePanel, BorderLayout.NORTH); - add(contentPane); -} + add(titlePanel, BorderLayout.NORTH); + add(contentPane); + } } |
