com.taursys.swing
Class MComboBox

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JComboBox
                  extended bycom.taursys.swing.MComboBox
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, EnableListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, javax.swing.event.ListDataListener, java.awt.MenuContainer, java.io.Serializable

public class MComboBox
extends javax.swing.JComboBox
implements EnableListener

MComboBox is a bound version of the JComboBox.

Version:
2.0
Author:
Marty Phelan
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComboBox
javax.swing.JComboBox.AccessibleJComboBox, javax.swing.JComboBox.KeySelectionManager
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
MComboBox()
          Constructs a new MComboBox with an empty list and default properties.
MComboBox(java.lang.Object[] items)
          Creates a MComboBox that contains the elements in the specified array.
 
Method Summary
 void enableChange(EnableEvent e)
          Invoked whenever an EnableChange event is generated by the model.
 java.lang.String getDisplayPropertyName()
          Get the property name of the list value to display.
 java.text.Format getFormat()
          Sets the format for the renderer which is used to format the list display value.
 java.lang.String getFormatPattern()
          Gets the format pattern for the renderer which is used to format the list display value.
 java.lang.String getListPropertyName()
          Get the property name in the ListValueHolder which will provide the selection value.
 java.lang.String[] getListPropertyNames()
          Get the property names in the ListValueHolder which will provide the selection values.
 ListValueHolder getListValueHolder()
          Get the valueHolder with the list of options for this component.
 MListCellRenderer getMListCellRenderer()
          Get the renderer cast as an MListCellRenderer.
 java.lang.String getNullDisplay()
          Returns value to display in list for a null value.
 java.lang.String getPropertyName()
          Get the property name in the ValueHolder which will store the selection.
 java.lang.String[] getPropertyNames()
          Get the property names in the ValueHolder which will store the selection.
 ValueHolder getValueHolder()
          Get the ValueHolder which will store the selection
 boolean isNullAllowed()
          Returns indicator that a null value is a valid selection.
 void setDisplayPropertyName(java.lang.String newDisplayPropertyName)
          Set the property name of the list value to display.
 void setFormat(java.text.Format newFormat)
          Sets the format for the renderer which is used to format the list display value.
 void setFormatPattern(java.lang.String newPattern)
          Sets the format pattern for the renderer which is used to format the list display value.
 void setListPropertyName(java.lang.String listPropertyName)
          Set the property name in the ListValueHolder which will provide the selection value.
 void setListPropertyNames(java.lang.String[] listPropertyNames)
          Set the property names in the ListValueHolder which will provide the selection values.
 void setListValueHolder(ListValueHolder holder)
          Set the valueHolder with the list of options for this component.
 void setModel(javax.swing.ComboBoxModel model)
          Binds this MComboBox to the given model.
 void setNullAllowed(boolean nullAllowed)
          Sets indicator that a null value is a valid selection.
 void setNullDisplay(java.lang.String text)
          Sets text to display in list for a null value.
 void setPropertyName(java.lang.String propertyName)
          Set the property name in the ValueHolder which will store the selection.
 void setPropertyNames(java.lang.String[] propertyNames)
          Set the property names in the ValueHolder which will store the selection.
 void setValueHolder(ValueHolder valueHolder)
          Set the ValueHolder which will store the selection
 
Methods inherited from class javax.swing.JComboBox
actionPerformed, addActionListener, addItem, addItemListener, addPopupMenuListener, configureEditor, configurePropertiesFromAction, contentsChanged, createActionPropertyChangeListener, createDefaultKeySelectionManager, fireActionEvent, fireItemStateChanged, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getAction, getActionCommand, getActionListeners, getEditor, getItemAt, getItemCount, getItemListeners, getKeySelectionManager, getMaximumRowCount, getModel, getPopupMenuListeners, getPrototypeDisplayValue, getRenderer, getSelectedIndex, getSelectedItem, getSelectedObjects, getUI, getUIClassID, hidePopup, insertItemAt, installAncestorListener, intervalAdded, intervalRemoved, isEditable, isLightWeightPopupEnabled, isPopupVisible, paramString, processKeyEvent, removeActionListener, removeAllItems, removeItem, removeItemAt, removeItemListener, removePopupMenuListener, selectedItemChanged, selectWithKeyChar, setAction, setActionCommand, setEditable, setEditor, setEnabled, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setPopupVisible, setPrototypeDisplayValue, 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, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
 

Constructor Detail

MComboBox

public MComboBox()
Constructs a new MComboBox with an empty list and default properties.


MComboBox

public MComboBox(java.lang.Object[] items)
Creates a MComboBox that contains the elements in the specified array. By default the first item in the array (and therefore the data model) becomes selected.

Parameters:
items - an array of objects to insert into the combo box
See Also:
DefaultComboBoxModel
Method Detail

getMListCellRenderer

public MListCellRenderer getMListCellRenderer()
Get the renderer cast as an MListCellRenderer.

Returns:
the renderer cast as an MListCellRenderer.
Throws:
java.lang.ClassCastException - if the current renderer is not a MListCellRenderer

setModel

public void setModel(javax.swing.ComboBoxModel model)
Binds this MComboBox to the given model. The given model should be an instance of MComboBoxModel for this component to function properly. This method registers this component as an EnableListener with the model.

Parameters:
model - the ComboBoxModel for this MComboBox

setFormat

public void setFormat(java.text.Format newFormat)
Sets the format for the renderer which is used to format the list display value.

Parameters:
newFormat - the format for the renderer which is used to format the list display value.

getFormat

public java.text.Format getFormat()
Sets the format for the renderer which is used to format the list display value.

Returns:
the format for the renderer which is used to format the list display value.

setFormatPattern

public void setFormatPattern(java.lang.String newPattern)
Sets the format pattern for the renderer which is used to format the list display value.

Parameters:
newPattern - the format pattern for the renderer which is used to format the list display value.

getFormatPattern

public java.lang.String getFormatPattern()
Gets the format pattern for the renderer which is used to format the list display value.

Returns:
the format pattern for the renderer which is used to format the list display value.

setDisplayPropertyName

public void setDisplayPropertyName(java.lang.String newDisplayPropertyName)
Set the property name of the list value to display. If the property name is null or blank, then value itself will be displayed.

Parameters:
newDisplayPropertyName - the property name of the list value to display.

getDisplayPropertyName

public java.lang.String getDisplayPropertyName()
Get the property name of the list value to display. If the property name is null or blank, then value itself will be displayed.

Returns:
the property name of the list value to display.

setValueHolder

public void setValueHolder(ValueHolder valueHolder)
Set the ValueHolder which will store the selection

Parameters:
valueHolder - the ValueHolder which will store the selection

getValueHolder

public ValueHolder getValueHolder()
Get the ValueHolder which will store the selection

Returns:
the ValueHolder which will store the selection

setPropertyName

public void setPropertyName(java.lang.String propertyName)
Set the property name in the ValueHolder which will store the selection. This name must correspond with the optionListPropertyName.

Parameters:
propertyName - the property name in the ValueHolder which will store the selection.

getPropertyName

public java.lang.String getPropertyName()
Get the property name in the ValueHolder which will store the selection. This name must correspond with the optionListPropertyName.

Returns:
the property name in the ValueHolder which will store the selection.

setPropertyNames

public void setPropertyNames(java.lang.String[] propertyNames)
Set the property names in the ValueHolder which will store the selection. The selection can be associated with multiple properties in the value holder. These property names must correspond to the optionListPropertyNames.

Parameters:
propertyNames - the property names in the ValueHolder which will store the selection.

getPropertyNames

public java.lang.String[] getPropertyNames()
Get the property names in the ValueHolder which will store the selection. The selection can be associated with multiple properties in the value holder. These property names must correspond to the optionListPropertyNames.

Returns:
the property names in the ValueHolder which will store the selection.

setListValueHolder

public void setListValueHolder(ListValueHolder holder)
Set the valueHolder with the list of options for this component.


getListValueHolder

public ListValueHolder getListValueHolder()
Get the valueHolder with the list of options for this component.

Returns:
the valueHolder with the list of options for this component.

setListPropertyName

public void setListPropertyName(java.lang.String listPropertyName)
Set the property name in the ListValueHolder which will provide the selection value. This name must correspond with the propertyName for the valueHolder.

Parameters:
listPropertyName - the property name in the ListValueHolder which will provide the selection value.

getListPropertyName

public java.lang.String getListPropertyName()
Get the property name in the ListValueHolder which will provide the selection value. This name must correspond with the propertyName for the valueHolder.

Returns:
the property name in the ListValueHolder which will provide the selection value.

setListPropertyNames

public void setListPropertyNames(java.lang.String[] listPropertyNames)
Set the property names in the ListValueHolder which will provide the selection values. These names must correspond with the propertyNames for the valueHolder.

Parameters:
listPropertyNames - the property names in the ListValueHolder which will provide the selection values.

getListPropertyNames

public java.lang.String[] getListPropertyNames()
Get the property names in the ListValueHolder which will provide the selection values. These names must correspond with the propertyNames for the valueHolder.

Returns:
the property names in the ListValueHolder which will provide the selection values.

setNullDisplay

public void setNullDisplay(java.lang.String text)
Sets text to display in list for a null value.


getNullDisplay

public java.lang.String getNullDisplay()
Returns value to display in list for a null value.


setNullAllowed

public void setNullAllowed(boolean nullAllowed)
Sets indicator that a null value is a valid selection. Default is false.


isNullAllowed

public boolean isNullAllowed()
Returns indicator that a null value is a valid selection. Default is false.


enableChange

public void enableChange(EnableEvent e)
Invoked whenever an EnableChange event is generated by the model. The model will issue the EnableChange event to indicate whether or not this control should allow edits. The enabled property is set based on this.

Specified by:
enableChange in interface EnableListener
Parameters:
e - EnableEvent indicating whether or not a control component be enabled.


Copyright © 2007 Martin T Phelan. All Rights Reserved.