org.vizzini.ui
Class AbstractOptionPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JOptionPane
                  extended by org.vizzini.ui.AbstractOptionPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
AboutDialog, AbstractAssociateDialog, EditFiltersDialog, HelpDialogSwing, NewGameDialogSwing, PawnPromotionDialogSwing, VisibleColumnsDialog

public abstract class AbstractOptionPane
extends JOptionPane

Provides a generic option pane base class for creating platform sensitive dialogs.

A subclass must override fillMainPanel( JPanel ) for its custom components, and getTitleKey() for its custom dialog title. A subclass should call fillMainPanel() in its constructor.

The default option type is OK_CANCEL_OPTION; other choices may be set by using setOptionType( int ) or setOptionType( int, String ). The latter allows custom button labels to be set on the OK button. The dialog is shown with optionPane.getDialog().show() and brought to the front with optionPane.getDialog().toFront().

For specialized closing behavior, subclasses may override the following methods:

Since:
v0.1
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JOptionPane
JOptionPane.AccessibleJOptionPane
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  String _title
          Full title including the owner title, if any.
static int APPLY_OPTION
          Added option for use with option type OK_CANCEL_APPLY_OPTION.
static int CUSTOM_CANCEL_APPLY_OPTION
          Added option type for a custom OK button.
static int CUSTOM_CANCEL_OPTION
          Added option type for a custom OK button.
static int CUSTOM_OPTION
          Added option type for a custom OK button.
static int OK_CANCEL_APPLY_OPTION
          Added option type.
 
Fields inherited from class javax.swing.JOptionPane
CANCEL_OPTION, CLOSED_OPTION, DEFAULT_OPTION, ERROR_MESSAGE, icon, ICON_PROPERTY, INFORMATION_MESSAGE, INITIAL_SELECTION_VALUE_PROPERTY, INITIAL_VALUE_PROPERTY, initialSelectionValue, initialValue, INPUT_VALUE_PROPERTY, inputValue, message, MESSAGE_PROPERTY, MESSAGE_TYPE_PROPERTY, messageType, NO_OPTION, OK_CANCEL_OPTION, OK_OPTION, OPTION_TYPE_PROPERTY, options, OPTIONS_PROPERTY, optionType, PLAIN_MESSAGE, QUESTION_MESSAGE, SELECTION_VALUES_PROPERTY, selectionValues, UNINITIALIZED_VALUE, value, VALUE_PROPERTY, WANTS_INPUT_PROPERTY, wantsInput, WARNING_MESSAGE, YES_NO_CANCEL_OPTION, YES_NO_OPTION, YES_OPTION
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
protected AbstractOptionPane()
          Construct this dialog.
protected AbstractOptionPane(Component parentComponent)
          Construct this dialog.
protected AbstractOptionPane(Component parentComponent, String ownerTitle)
          Construct this dialog.
 
Method Summary
protected  void applyActionPerformed()
          Callback for the apply button.
protected  void cancelActionPerformed()
          Callback for the cancel button.
protected  void checkComponents()
          Check components for their enable state.
protected  void closedActionPerformed()
          Callback for the window closed button.
protected  JPanel createMainPanel()
          Create the main panel which is placed in the message area of the option pane.
protected  void fillMainPanel()
          Fill the main panel which is placed in the message area of the option pane.
protected abstract  void fillMainPanel(JPanel mainPanel)
          Fill the main panel which is placed in the message area of the option pane.
protected  boolean findAndSetDefaultButton(Component[] components)
          Locate and set the default button.
 JDialog getDialog()
          Return the dialog for this option pane, creating it if necessary.
protected  JPanel getMainPanel()
          Return the main panel.
 int getOptionType()
          Extend the super method to handle OK_CANCEL_APPLY_OPTION, CUSTOM_OPTION, CUSTOM_CANCEL_OPTION, and CUSTOM_CANCEL_APPLY_OPTION.
protected  String getOwnerTitle()
          Return the owner title.
 int getResult()
          Return the result.
protected abstract  String getTitleKey()
          Return the title string key.
protected  void init(Component parentComponent, String ownerTitle)
          Initialize this option pane.
protected static void initializeOptionStrings()
          Initialize the option strings.
 boolean isActionApproved()
          Return true if the dialog was approved.
 boolean isDirty()
          Answer true if data was changed in the dialog.
protected  void noActionPerformed()
          Callback for the no button.
protected  void okActionPerformed()
          Callback for the OK button.
protected  void performUpdates()
          Provides a hook for updating the dialog contents.
protected  void processResult()
          Process the result.
 void setCursorBusy(boolean busy)
          Set the cursor to show busy.
 void setDirty(boolean isDirty)
          Set the dirty flag.
 void setOptionType(int optionType)
          Extend the super method to handle OK_CANCEL_APPLY_OPTION.
 void setOptionType(int optionType, String customKey)
          Extend the super method to handle CUSTOM_OPTION, CUSTOM_CANCEL_OPTION, and CUSTOM_CANCEL_APPLY_OPTION.
protected  void setTitle(String title)
          Set the title of this dialog.
 
Methods inherited from class javax.swing.JOptionPane
createDialog, createInternalFrame, getAccessibleContext, getDesktopPaneForComponent, getFrameForComponent, getIcon, getInitialSelectionValue, getInitialValue, getInputValue, getMaxCharactersPerLineCount, getMessage, getMessageType, getOptions, getRootFrame, getSelectionValues, getUI, getUIClassID, getValue, getWantsInput, paramString, selectInitialValue, setIcon, setInitialSelectionValue, setInitialValue, setInputValue, setMessage, setMessageType, setOptions, setRootFrame, setSelectionValues, setUI, setValue, setWantsInput, showConfirmDialog, showConfirmDialog, showConfirmDialog, showConfirmDialog, showInputDialog, showInputDialog, showInputDialog, showInputDialog, showInputDialog, showInputDialog, showInternalConfirmDialog, showInternalConfirmDialog, showInternalConfirmDialog, showInternalConfirmDialog, showInternalInputDialog, showInternalInputDialog, showInternalInputDialog, showInternalMessageDialog, showInternalMessageDialog, showInternalMessageDialog, showInternalOptionDialog, showMessageDialog, showMessageDialog, showMessageDialog, showOptionDialog, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

APPLY_OPTION

public static final int APPLY_OPTION
Added option for use with option type OK_CANCEL_APPLY_OPTION. Uses applyActionPerformed().

See Also:
Constant Field Values

CUSTOM_OPTION

public static final int CUSTOM_OPTION
Added option type for a custom OK button. Uses okActionPerformed().

See Also:
Constant Field Values

CUSTOM_CANCEL_OPTION

public static final int CUSTOM_CANCEL_OPTION
Added option type for a custom OK button. Uses okActionPerformed() and cancelActionPerformed().

See Also:
Constant Field Values

CUSTOM_CANCEL_APPLY_OPTION

public static final int CUSTOM_CANCEL_APPLY_OPTION
Added option type for a custom OK button. Uses okActionPerformed(), cancelActionPerformed(), and applyActionPerformed().

See Also:
Constant Field Values

OK_CANCEL_APPLY_OPTION

public static final int OK_CANCEL_APPLY_OPTION
Added option type.

See Also:
Constant Field Values

_title

protected String _title
Full title including the owner title, if any.

Constructor Detail

AbstractOptionPane

protected AbstractOptionPane()
Construct this dialog. The default option type is OK_CANCEL_OPTION.

Since:
v0.1

AbstractOptionPane

protected AbstractOptionPane(Component parentComponent)
Construct this dialog. The default option type is OK_CANCEL_OPTION.

Parameters:
parentComponent - The parent component.
Since:
v0.1

AbstractOptionPane

protected AbstractOptionPane(Component parentComponent,
                             String ownerTitle)
Construct this dialog. The default option type is OK_CANCEL_OPTION.

Parameters:
parentComponent - The parent component.
ownerTitle - Title representing the owning application.
Since:
v0.1
Method Detail

getDialog

public JDialog getDialog()
Return the dialog for this option pane, creating it if necessary.

Since:
v0.1

getOptionType

public int getOptionType()
Extend the super method to handle OK_CANCEL_APPLY_OPTION, CUSTOM_OPTION, CUSTOM_CANCEL_OPTION, and CUSTOM_CANCEL_APPLY_OPTION.

Overrides:
getOptionType in class JOptionPane
Since:
v0.1

getResult

public int getResult()
Return the result.

Since:
v0.1

isActionApproved

public boolean isActionApproved()
Return true if the dialog was approved.

Since:
v0.1

isDirty

public boolean isDirty()
Answer true if data was changed in the dialog.

Since:
v0.1

setCursorBusy

public void setCursorBusy(boolean busy)
Set the cursor to show busy.

Since:
v0.1

setDirty

public void setDirty(boolean isDirty)
Set the dirty flag.

Since:
v0.1

setOptionType

public void setOptionType(int optionType)
Extend the super method to handle OK_CANCEL_APPLY_OPTION.

Overrides:
setOptionType in class JOptionPane
Parameters:
optionType - Option type.
Since:
v0.1

setOptionType

public void setOptionType(int optionType,
                          String customKey)
Extend the super method to handle CUSTOM_OPTION, CUSTOM_CANCEL_OPTION, and CUSTOM_CANCEL_APPLY_OPTION.

Parameters:
optionType - Option type.
customKey - Resource key for the custom button text.
Throws:
IllegalArgumentException - if optionType is not one of CUSTOM_OPTION, CUSTOM_CANCEL_OPTION, or CUSTOM_CANCEL_APPLY_OPTION.
Since:
v0.1

fillMainPanel

protected abstract void fillMainPanel(JPanel mainPanel)
Fill the main panel which is placed in the message area of the option pane.

Since:
v0.1

getTitleKey

protected abstract String getTitleKey()
Return the title string key.

Since:
v0.1

initializeOptionStrings

protected static void initializeOptionStrings()
Initialize the option strings. These can't be static final because ApplicationSupport must be initialized first.

Since:
v0.1

applyActionPerformed

protected void applyActionPerformed()
Callback for the apply button.

Since:
v0.1

cancelActionPerformed

protected void cancelActionPerformed()
Callback for the cancel button.

Since:
v0.1

checkComponents

protected void checkComponents()
Check components for their enable state. This method is called when the dirty flag is changed.

Since:
v0.1

closedActionPerformed

protected void closedActionPerformed()
Callback for the window closed button.

Since:
v0.1

createMainPanel

protected JPanel createMainPanel()
Create the main panel which is placed in the message area of the option pane. The default layout is BorderLayout with horizontal and vertical gaps of size GUIConstants.GAP.

Since:
v0.2

fillMainPanel

protected void fillMainPanel()
Fill the main panel which is placed in the message area of the option pane. This is a convenience method intended to be called by subclasses in their constructor.

Since:
v0.1

findAndSetDefaultButton

protected boolean findAndSetDefaultButton(Component[] components)
Locate and set the default button.

Since:
v0.1

getMainPanel

protected JPanel getMainPanel()
Return the main panel.

Since:
v0.1

getOwnerTitle

protected String getOwnerTitle()
Return the owner title.

Since:
v0.1

init

protected void init(Component parentComponent,
                    String ownerTitle)
Initialize this option pane.

Since:
v0.1

noActionPerformed

protected void noActionPerformed()
Callback for the no button.

Since:
v0.1

okActionPerformed

protected void okActionPerformed()
Callback for the OK button.

Since:
v0.1

performUpdates

protected void performUpdates()
Provides a hook for updating the dialog contents.

Since:
v0.3

processResult

protected void processResult()
Process the result.

Since:
v0.1

setTitle

protected void setTitle(String title)
Set the title of this dialog. The owner title, if any, is prepended. This method must be used before the first call to getDialog() in order for the title to take effect.

Parameters:
title - New title.
Since:
v0.1


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02