org.ceryle.ui
Class OptionDialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by org.ceryle.ui.OptionDialog
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class OptionDialog
extends JDialog

Extends JDialog providing a set of radio buttons for making a multiple-option decision. The result is returned as an int (indicating which of the options was selected) via getResult(), -1 if none were selected or the dialog was cancelled.

The supplied options can be in one of two forms, either a List of Strings, or a List of String[] arrays, the latter pairings where the first String is the displayed item, the second descriptive text that shows up in a Help box when the item is selected. If the help text is a single token it will be treated as the ID of a Help tutorial, such that clicking the Help button will instead load that tutorial.

Note that if one of the list options is akin to "Cancel this operation.", the display of the Cancel button should be suppressed with a "false" parameter value for includeCancel, since selecting this option means the same thing.

The help text area supports simple HTML 3.2-era presentational markup.

Since:
JDK1.3
Version:
$Id: OptionDialog.java,v 3.12 2007-06-20 01:28:19 altheim Exp $
Author:
Murray Altheim
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
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
static boolean defaultHelpVisible
          A flag indicating the initial visibility of help.
static int dlog_width
          The preferred width of the dialog.
static int scroll_minimum
          The maximum number of list items prior to using a scrolling list.
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
OptionDialog(Desktop desktop, String title, String message, List options, boolean[] enables, int defaultOption, String help, boolean includeCancel)
          Constructor for a dialog box for selecting amongst a set of options.
OptionDialog(Desktop desktop, String title, String message, List options, int defaultOption, String help, boolean includeCancel)
          Constructor for a dialog box for selecting amongst a set of options.
OptionDialog(String title, String message, List options, int defaultOption, String help, boolean includeCancel)
          Constructor for a dialog box for selecting amongst a set of options.
 
Method Summary
 int getSelected()
          Returns the number of the selected option (starting at 1, not 0).
 void setSelected(JRadioButton button)
          Sets the selected option.
 void setVisible(boolean visible)
          Overrides the superclass to additionally re-set the graph display priority.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultHelpVisible

public static boolean defaultHelpVisible
A flag indicating the initial visibility of help. Default is false.


scroll_minimum

public static int scroll_minimum
The maximum number of list items prior to using a scrolling list.


dlog_width

public static int dlog_width
The preferred width of the dialog. The default is 500.

Constructor Detail

OptionDialog

public OptionDialog(String title,
                    String message,
                    List options,
                    int defaultOption,
                    String help,
                    boolean includeCancel)
Constructor for a dialog box for selecting amongst a set of options. The supplied options are a List containing either a set of two String arrays (where the first is the label, the second its help text), single Strings, or Objects with an acceptable toString() method. Note that if the help String is null, no 'Help' button will be available, even for the radio button help texts. This will use the application Desktop as the owner Frame.

Parameters:
title - the dialog title
message - the message or question, which can include HTML markup
options - the List of Strings, a List of String[] or Object[]
defaultOption - the number of the default (selected) choice, -1 if none.
help - optional help text, or if a single token, the Help ID.
includeCancel - include cancel button?

OptionDialog

public OptionDialog(Desktop desktop,
                    String title,
                    String message,
                    List options,
                    int defaultOption,
                    String help,
                    boolean includeCancel)
Constructor for a dialog box for selecting amongst a set of options. The supplied options are a List containing either a set of two String arrays (where the first is the label, the second its help text), single Strings, or Objects with an acceptable toString() method. Note that if the help String is null, no 'Help' button will be available, even for the radio button help texts.

Parameters:
desktop - the parent application
title - the dialog title
message - the message or question, which can include HTML markup
options - the List of Strings, a List of String[] or Object[]
defaultOption - the number of the default (selected) choice, -1 if none.
help - optional help text, or if a single token, the Help ID.
includeCancel - include cancel button?

OptionDialog

public OptionDialog(Desktop desktop,
                    String title,
                    String message,
                    List options,
                    boolean[] enables,
                    int defaultOption,
                    String help,
                    boolean includeCancel)
Constructor for a dialog box for selecting amongst a set of options. The supplied options are a List containing either a set of two String arrays (where the first is the label, the second its help text), single Strings, or Objects with an acceptable toString() method. Note that if the help String is null, no 'Help' button will be available, even for the radio button help texts.

Parameters:
desktop - the parent application
title - the dialog title
message - the message or question, which can include HTML markup
options - the List of Strings, a List of String[] or Object[]
enables - an optional boolean array (size must match count of objects or is ignored)
defaultOption - the number of the default (selected) choice, -1 if none.
help - optional help text, or if a single token, the Help ID.
includeCancel - include cancel button?
Method Detail

setVisible

public void setVisible(boolean visible)
Overrides the superclass to additionally re-set the graph display priority.

Overrides:
setVisible in class Component

getSelected

public int getSelected()
Returns the number of the selected option (starting at 1, not 0). Returns -1 if no selection was made or the dialog was cancelled.


setSelected

public void setSelected(JRadioButton button)
Sets the selected option. If the original source content included help text, this is displayed in the Help area.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.