jimmc.swing
Class ComboBoxAction

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JComboBox
                          |
                          +--jimmc.swing.ComboBoxAction
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.lang.Cloneable, EditField, java.util.EventListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, javax.swing.event.ListDataListener, java.awt.MenuContainer, java.io.Serializable

public class ComboBoxAction
extends javax.swing.JComboBox
implements java.awt.event.ActionListener, EditField, java.lang.Cloneable

An adapter class to simplify defining ComboBoxes with actions.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JComboBox
javax.swing.JComboBox.AccessibleJComboBox, javax.swing.JComboBox.KeySelectionManager
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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  ResourceSource res
          Our resource source for error messages.
protected  java.lang.Object[] values
          Our values, if different from the displayed value.
 
Fields inherited from class javax.swing.JComboBox
actionCommand, dataModel, editor, isEditable, keySelectionManager, lightWeightPopupEnabled, maximumRowCount, renderer, selectedItemReminder
 
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
ComboBoxAction()
          Create a button with no resource source.
ComboBoxAction(ResourceSource res)
          Create a button.
 
Method Summary
 void action()
          The default action for this button.
 void actionPerformed(java.awt.event.ActionEvent ev)
          Here on an action event.
 EditField cloneEditField()
          Clone us.
 java.lang.Object getDisplayForValue(java.lang.Object value)
          Get the display value for a specified actual value.
 java.lang.String getSelectedString()
          Get the currently selected and displayed string.
 java.lang.Object getValue()
          Get the currently selected value.
 java.lang.Object getValueForDisplay(java.lang.Object display)
          Get the actual value for a specified display value.
 void setChoices(java.lang.Object[] values, java.lang.Object[] displays)
          Set values and separate displayed data.
 void setItems(java.lang.Object[] displays)
          Set all our choices at once.
 void setValue(java.lang.Object value)
          Set the current value.
 
Methods inherited from class javax.swing.JComboBox
addActionListener, addItem, addItemListener, configureEditor, configurePropertiesFromAction, contentsChanged, createActionPropertyChangeListener, createDefaultKeySelectionManager, fireActionEvent, fireItemStateChanged, getAccessibleContext, getAction, getActionCommand, getEditor, getItemAt, getItemCount, getKeySelectionManager, getMaximumRowCount, getModel, getRenderer, getSelectedIndex, getSelectedItem, getSelectedObjects, getUI, getUIClassID, hidePopup, insertItemAt, installAncestorListener, intervalAdded, intervalRemoved, isEditable, isFocusTraversable, isLightWeightPopupEnabled, isPopupVisible, paramString, processKeyEvent, removeActionListener, removeAllItems, removeItem, removeItemAt, removeItemListener, selectedItemChanged, selectWithKeyChar, setAction, setActionCommand, setEditable, setEditor, setEnabled, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setModel, setPopupVisible, setRenderer, setSelectedIndex, setSelectedItem, setUI, showPopup, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

res

protected ResourceSource res
Our resource source for error messages.

values

protected java.lang.Object[] values
Our values, if different from the displayed value.
Constructor Detail

ComboBoxAction

public ComboBoxAction(ResourceSource res)
Create a button.

ComboBoxAction

public ComboBoxAction()
Create a button with no resource source.
Method Detail

cloneEditField

public EditField cloneEditField()
Clone us.
Specified by:
cloneEditField in interface EditField

setItems

public void setItems(java.lang.Object[] displays)
Set all our choices at once. This is faster than using addItem for each one.

setChoices

public void setChoices(java.lang.Object[] values,
                       java.lang.Object[] displays)
Set values and separate displayed data.
Parameters:
values - The values to be set with setValue(java.lang.Object) and returned by getValue().
displays - The data to be displayed on the screen.

getSelectedString

public java.lang.String getSelectedString()
Get the currently selected and displayed string.

setValue

public void setValue(java.lang.Object value)
Set the current value. If setChoices(java.lang.Object[], java.lang.Object[]) has been called, the value here must be one of the values from the values list passed to setChoices. If setItems(java.lang.Object[]) has been called, or neither has been called, the value here must be one of the displayed values.
Specified by:
setValue in interface EditField

getValue

public java.lang.Object getValue()
Get the currently selected value. If setChoices(java.lang.Object[], java.lang.Object[]) has been called, returns one of the values rather than the displayed data. If setItems(java.lang.Object[]) has been called, or neither has been called, returns the displayed data.
Specified by:
getValue in interface EditField

getValueForDisplay

public java.lang.Object getValueForDisplay(java.lang.Object display)
Get the actual value for a specified display value.

getDisplayForValue

public java.lang.Object getDisplayForValue(java.lang.Object value)
Get the display value for a specified actual value.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ev)
Here on an action event.
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Overrides:
actionPerformed in class javax.swing.JComboBox

action

public void action()
The default action for this button. The subclass usually overrides this method.