dsto.dfc.swing.controls
Class RadioBox

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by dsto.dfc.swing.forms.AbstractFormEditorComponent
                  extended by dsto.dfc.swing.controls.RadioBox
All Implemented Interfaces:
FormEditor, Disposable, ActionListener, ImageObserver, MenuContainer, Customizer, Serializable, EventListener

public class RadioBox
extends AbstractFormEditorComponent
implements Disposable, ActionListener

A control that presents a multiple choice selection as a set of radio buttons. Supports auto-setup of choices when possible values are defined by an EnumerationValue and is also a FormEditor.

Version:
$Revision$
Author:
Matthew
See Also:
Serialized Form

Nested Class Summary
 
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int LAYOUT_HORIZONTAL
          Lay out radio buttons horizontally.
static int LAYOUT_VERTICAL
          Lay out radio buttons vertically.
 
Fields inherited from class dsto.dfc.swing.forms.AbstractFormEditorComponent
description
 
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
RadioBox()
          Create radio box with no selectable options.
RadioBox(Object[] possibleValues)
           
RadioBox(Object[] possibleValues, int orientation)
          Create a new radio box.
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void commitEdits()
          Default implementation does nothing.
protected  void createRadioButtons()
           
protected  void destroyRadioButtons()
           
 void dispose()
          Dispose of the object (unregister listeners, close open resources etc).
protected  int findIndexInPossibleValues(Object value)
          Find the index of a value in the array of possible values.
 int getButtonOrientation()
           
 Object getEditorValue()
          Get the current value from the form editor.
 String[] getPossibleStringValues()
           
 Object[] getPossibleValues()
           
 JRadioButton getSelectedButton()
           
 String getSelectedStringValue()
           
 boolean isDirectEdit()
          True if the editor directly edits the value passed in with setValue ().
 void requestFocus()
           
 void setButtonOrientation(int newValue)
          Set the orientation of the radio buttons.
 void setEditorValue(Object newValue)
          Set the editor value (ie the current selected value).
 void setEnabled(boolean enabled)
           
 void setPossibleStringValues(String[] newValues)
          Convenience method to present possibleValues property as a String array for visual bean builders.
 void setPossibleValues(Object[] newValues)
          Set the possible values that can be selected from.
 void setSelectedStringValue(String value)
           
 
Methods inherited from class dsto.dfc.swing.forms.AbstractFormEditorComponent
addFormEditorListener, fireEditComitted, fireEditCommitRequested, fireEditCommitted, getEditorComponent, getEditorDescription, getPreferredValueType, removeFormEditorListener, setEditorDescription, setObject
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
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
 
Methods inherited from interface java.beans.Customizer
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

LAYOUT_HORIZONTAL

public static final int LAYOUT_HORIZONTAL
Lay out radio buttons horizontally.

See Also:
Constant Field Values

LAYOUT_VERTICAL

public static final int LAYOUT_VERTICAL
Lay out radio buttons vertically.

See Also:
Constant Field Values
Constructor Detail

RadioBox

public RadioBox()
Create radio box with no selectable options. Either use setPossibleValues(java.lang.Object[]) or use editor values implementing the EnumerationValue interface to set the possible values.


RadioBox

public RadioBox(Object[] possibleValues)

RadioBox

public RadioBox(Object[] possibleValues,
                int orientation)
Create a new radio box.

Parameters:
possibleValues - The selectable values displayed as radio buttons in the box. May be null.
orientation - The orientation of the buttons (LAYOUT_VERTICAL or LAYOUT_HORIZONTAL).
Method Detail

setPossibleValues

public void setPossibleValues(Object[] newValues)
Set the possible values that can be selected from. Each value will be displayed as a radio button.

Parameters:
newValues - The new set of possible values.

getPossibleValues

public Object[] getPossibleValues()

setPossibleStringValues

public void setPossibleStringValues(String[] newValues)
Convenience method to present possibleValues property as a String array for visual bean builders.


getPossibleStringValues

public String[] getPossibleStringValues()

getSelectedStringValue

public String getSelectedStringValue()

setSelectedStringValue

public void setSelectedStringValue(String value)
                            throws IllegalFormatException
Throws:
IllegalFormatException

setButtonOrientation

public void setButtonOrientation(int newValue)
Set the orientation of the radio buttons.

Parameters:
newValue - Either LAYOUT_HORIZONTAL or LAYOUT_VERTICAL.

getButtonOrientation

public int getButtonOrientation()

dispose

public void dispose()
Description copied from interface: Disposable
Dispose of the object (unregister listeners, close open resources etc). It should be safe to call this method more than once. Note for beans that support client event listeners: if there are listeners registered when this is called, this method should do nothing.

Specified by:
dispose in interface Disposable

setEnabled

public void setEnabled(boolean enabled)
Overrides:
setEnabled in class JComponent

requestFocus

public void requestFocus()
Overrides:
requestFocus in class JComponent

getSelectedButton

public JRadioButton getSelectedButton()

createRadioButtons

protected void createRadioButtons()

destroyRadioButtons

protected void destroyRadioButtons()

findIndexInPossibleValues

protected int findIndexInPossibleValues(Object value)
Find the index of a value in the array of possible values.


isDirectEdit

public boolean isDirectEdit()
Description copied from interface: FormEditor
True if the editor directly edits the value passed in with setValue (). If false, the parent editor will be reponsible for retrieving the value from the editor and storing it.

Specified by:
isDirectEdit in interface FormEditor
Specified by:
isDirectEdit in class AbstractFormEditorComponent

setEditorValue

public void setEditorValue(Object newValue)
                    throws IllegalFormatException
Set the editor value (ie the current selected value).

Specified by:
setEditorValue in interface FormEditor
Specified by:
setEditorValue in class AbstractFormEditorComponent
Parameters:
newValue - The new value. If newValue implements the EnumerationValue interface, then the possible values for this control are automatically set to its enumValues property.
Throws:
IllegalFormatException - if the value was not in the correct format for display by this editor. The source specified by the exception should be this FormEditor instance or a child.

getEditorValue

public Object getEditorValue()
Description copied from interface: FormEditor
Get the current value from the form editor. At least one call to setValue () must be made beforehand.

Specified by:
getEditorValue in interface FormEditor
Specified by:
getEditorValue in class AbstractFormEditorComponent

commitEdits

public void commitEdits()
Description copied from class: AbstractFormEditorComponent
Default implementation does nothing.

Specified by:
commitEdits in interface FormEditor
Overrides:
commitEdits in class AbstractFormEditorComponent

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener


Copyright © 2008 Commonwealth of Australia