qflib 0.98.0

de.qfs.lib.option
Class OptionDialog

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Dialog
                          |
                          +--javax.swing.JDialog
                                |
                                +--de.qfs.lib.gui.ModalDialog
                                      |
                                      +--de.qfs.lib.option.OptionDialog
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants, java.awt.event.WindowListener

public class OptionDialog
extends ModalDialog

This class offers a convenient way to bring up a dialog in which an application's options can be edited.

Since version 0.98.0 this class is based on ModalDialog, so the buttons of the dialog can be customized easily. Please see the documentation for ModalDialog about the resources used.

OptionDialog defines one additional resource for each button: dialog.button.name.set. If true, pressing the button causes the values the user entered to be read from the dialog and stored in the options. If this fails due to illegal values, the action is aborted. The default for the set property is false.

If no name resource is defined for the dialog, its AWT name is set to "OptionDialog-<root>-<options>" where <root> is the resource name of the root OptionGroup and <options> is the configurable name of the OptionSet being edited.

Version:
$Revision: 1.4 $
Author:
Gregor Schmid
See Also:
Serialized Form

Inner Class Summary
protected static class OptionDialog.OptionButtonData
          Extend the structure that encapsulates the values for a button.
 
Inner classes inherited from class de.qfs.lib.gui.ModalDialog
ModalDialog.ButtonData
 
Inner classes inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Inner classes inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog
 
Inner classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  OptionGroup optionGroup
          The OptionGroup displayed in the dialog.
protected  OptionSet options
          The Options to edit.
protected  java.awt.Window parent
          The parent Window for the Dialog.
protected  java.lang.String root
          The name of the root OptionGroup.
 
Fields inherited from class de.qfs.lib.gui.ModalDialog
buttons, CANCEL_OPTION, CLOSED_OPTION, defaultButtons, layout, mainComponent, mainPanel, minHeight, minWidth, name, NO_OPTION, OK_OPTION, panel, retval, YES_OPTION
 
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, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
OptionDialog(java.awt.Frame parent, java.lang.String title, OptionSet options, java.lang.String root)
          Deprecated. Replaced with OptionDialog as of version 0.98.0.
OptionDialog(java.lang.String name, java.awt.Dialog parent, OptionSet options, java.lang.String root)
          Create a new OptionDialog.
OptionDialog(java.lang.String name, java.awt.Frame parent, OptionSet options, java.lang.String root)
          Create a new OptionDialog.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Handler for a button press.
 boolean doModal()
          Bring up the Dialog and wait for the user to finish editing.
 OptionGroup getGroup()
          Get the OptionGroup of the dialog.
 int getResult()
          Get the result for the last doModal operation.
protected  ModalDialog.ButtonData initButton(java.lang.String bname, MapResourceBundle rb)
          Initialize one button.
protected  void initComponent()
          Initialize the OptionGroup.
 boolean readValues()
          Read the current values from the dialog, store them in the options and notify the observers.
 void setParent(java.awt.Frame parent)
          Deprecated. The window's owner cannot really be changed. To place the dialog relative to some component use doModal(Component,boolean).
 void update(OptionSet options)
          Update the display of the OptionGroups.
 
Methods inherited from class de.qfs.lib.gui.ModalDialog
buttonResName, doModal, findButton, fixSize, getButton, getButton, getButtonCount, init, initButtonNames, resName, setMainComponent, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setLocationRelativeTo, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, dispose, getTitle, hide, isModal, isResizable, setModal, setResizable, setTitle, show
 
Methods inherited from class java.awt.Window
addWindowListener, applyResourceBundle, applyResourceBundle, finalize, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, isShowing, pack, postEvent, processEvent, removeWindowListener, setCursor, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, 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, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

options

protected OptionSet options
The Options to edit.

root

protected java.lang.String root
The name of the root OptionGroup.

optionGroup

protected OptionGroup optionGroup
The OptionGroup displayed in the dialog.

parent

protected java.awt.Window parent
The parent Window for the Dialog.
Constructor Detail

OptionDialog

public OptionDialog(java.awt.Frame parent,
                    java.lang.String title,
                    OptionSet options,
                    java.lang.String root)
Deprecated. Replaced with OptionDialog as of version 0.98.0.

Create a new OptionDialog.
Parameters:
parent - The parent Frame.
title - The title to display.
options - The Options to edit.
root - The resource name of the root of the OptionGroups. If null, the configurable name of the OptionSet will be used.

OptionDialog

public OptionDialog(java.lang.String name,
                    java.awt.Frame parent,
                    OptionSet options,
                    java.lang.String root)
Create a new OptionDialog.
Parameters:
name - The resource name of the dialog.
parent - The parent Frame.
options - The Options to edit.
root - The resource name of the root of the OptionGroups. If null, the configurable name of the OptionSet will be used.
Since:
0.98.0

OptionDialog

public OptionDialog(java.lang.String name,
                    java.awt.Dialog parent,
                    OptionSet options,
                    java.lang.String root)
Create a new OptionDialog.
Parameters:
name - The resource name of the dialog.
parent - The parent Dialog.
options - The Options to edit.
root - The resource name of the root of the OptionGroups. If null, the configurable name of the OptionSet will be used.
Since:
0.98.0
Method Detail

readValues

public boolean readValues()
Read the current values from the dialog, store them in the options and notify the observers.
Returns:
True if everything was OK, false if there are illegal values. In the latter case no options are changed.
Since:
0.98.0

update

public void update(OptionSet options)
Update the display of the OptionGroups.
Parameters:
options - The Options to use. Null means use original Options.

doModal

public boolean doModal()
Bring up the Dialog and wait for the user to finish editing. If the user confirms the actions with OK, all input will be checked for validity and the Options will be set accordingly. All Observers will be notified.

To get the full benefit of the configurable buttons, use doModal(Component,boolean) instead.

Returns:
True, if completed with the OK Button, false if canceled.

setParent

public void setParent(java.awt.Frame parent)
Deprecated. The window's owner cannot really be changed. To place the dialog relative to some component use doModal(Component,boolean).

Update the parent of the dialog, so the same Dialog can be reused with different parent Frames.
Parameters:
parent - The parent Frame to set.

getGroup

public OptionGroup getGroup()
Get the OptionGroup of the dialog.
Returns:
The dialog's OptionGroup.
Since:
0.98.0

getResult

public final int getResult()
Get the result for the last doModal operation. This is necessary to determine the button the user selected.
Returns:
-1 if the dialog was canceled, 0 for the first custom or the OK button, 1 for the second custom or the Cancel button, 2 and above for further custom buttons.

initComponent

protected void initComponent()
Initialize the OptionGroup.
Overrides:
initComponent in class ModalDialog

initButton

protected ModalDialog.ButtonData initButton(java.lang.String bname,
                                            MapResourceBundle rb)
Initialize one button. Overridden to create an OptionButtonData instead of a ButtonData.
Overrides:
initButton in class ModalDialog
Parameters:
bname - The resource name of the button.
rb - The resources to use.
Returns:
The initialized button.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Handler for a button press. If the button's close property is set, its return value is determined and the dialog is closed.
Overrides:
actionPerformed in class ModalDialog
Parameters:
e - The event containing the details.

qflib 0.98.0