planetj.gui
Class CMComboBoxJ

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JComboBox
                          |
                          +--planetj.gui.CMComboBoxJ
All Implemented Interfaces:
Accessible, ActionListener, EventListener, ImageObserver, ItemSelectable, ListDataListener, MenuContainer, Serializable, TableCellRenderer

public class CMComboBoxJ
extends JComboBox
implements TableCellRenderer

Common Swing JComboBox that provides I18N and business object support for loading the combo box with a vector of business objects.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
CMComboBoxJ()
          Insert the method's description here.
CMComboBoxJ(ComboBoxModel aModel)
          CMComboBox constructor comment.
CMComboBoxJ(Object[] items)
          CMComboBox constructor comment.
CMComboBoxJ(Vector items)
          CMComboBox constructor comment.
 
Method Summary
 void addBusinessObject(Object obj)
          Adds a business object into the business object vector Creation date: (8/8/00 12:11:03 PM)
 void addItem(Object item)
          Translate the items if it is a String and add it to the ComboBox.
 void addItemDirectly(Object item)
          Add an item to the ComboBox with NO translation! Record it as the translated and original!
 void blink(int times, Color blinkColor)
          Makes the combo box blink
 boolean contains(Object item)
          Check to see if this combo box contains the parameter Creation date: (8/7/2003 8:58:48 PM)
 boolean getApplicable()
          adds a bit more functionality than enabled alone
 List getBusinessObjects()
          Return a Vector of businessObjects
 boolean getEnabled()
          adds a bit more functionality than enabled alone
 boolean getForceUpperCase()
          gets the upper case boolean value
 String getGetterMethod()
          Gets the getterMethod String.
 List getItems()
          Gets the Items in a List of Strings that has been translated.
 List getOriginalStrings()
          Return a List of Strings that are the pre-translated Strings displayed in this component.
 Object getSelectedBusinessObject()
          Return a businessObject that is being selected from the ComboBox Returns -1 if nothing was selected.
 String getSelectedId()
          Should use getSelectedOriginalString().
 String getSelectedOriginalString()
          Return the original (pre - translation) string that is currently being selected.
 Component getTableCellRendererComponent(JTable table, Object obj, boolean isSelected, boolean hasFocus, int row, int column)
          This ComboBox can act as a TableCellRenderer,
 boolean isAllowDuplicates()
          This will enforce whether this combo box allows duplicate entries This checks to see if one value equals another.
 boolean isAlphabeticalSortRequired()
          isAlphabeticalSortRequired method this method returns whether or not the BusinessObjects should be sorted in alphabetical order
 boolean isNoneInList()
          isNoneInList tells whether or not *NONE appears at the top of the list
static void main(String[] args)
          main entrypoint - starts the part when it is run as an application
 void removeBusinessObject(Object obj)
          Removes a business object from the business object vector Creation date: (8/8/00 12:11:03 PM)
 void selectedItemChanged()
          Need to override to trigger the "selectedBusinessObject" property change
 void setAllowDuplicates(boolean newAllowDuplicates)
          This will enforce whether this combo box allows duplicate entries This checks to see if one value equals another.
 void setAlphabeticalSortRequired(boolean value)
          setAlphabeticalSortRequired method sets whether or not the BusinessObjects should be sorted.
 void setApplicable(boolean e)
          adds a bit more functionality than enabled alone
 void setBusinessObjects(List businessObjects)
          Set a List of business objects into the JComboBox.
 void setEnabled(boolean e)
          override the super method to do a bit more
 void setForceUpperCase(boolean uc)
          Sets the upper case boolean
 void setGetterMethod(String getterMethod)
          Set a methodName to be used to query a business objects for a String that will be used as the items within a JComboBox.
 void setItems(List newItems)
          Translate the Vector of Strings and then set the translated Strings in the component.
 void setItemsDirectly(List newTranslation)
          Add a List of Strings to the ComboBox directly.
 void setNoneInList(boolean value)
          setNoneInList sets whether or not *NONE is an option in the list
 void setSelectedBusinessObject(Object selectedBusinessObject)
          Sets the selected item and handles nulls too.
 void setSelectedId(String selectedId)
          Should use setSelectedOriginalString.
 void setSelectedOriginalString(String originalString)
          Set the comboBox's selected index to the position occupied by the originalString
 void setTranslation(List newTranslation)
          Should use setItemsDirectly() instead of this method! Sets the Vector of Strings as the items to display in this component.
 
Methods inherited from class javax.swing.JComboBox
actionPerformed, addActionListener, addItemListener, addPopupMenuListener, configureEditor, contentsChanged, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getAction, getActionCommand, getActionListeners, getEditor, getItemAt, getItemCount, getItemListeners, getKeySelectionManager, getMaximumRowCount, getModel, getPopupMenuListeners, getPrototypeDisplayValue, getRenderer, getSelectedIndex, getSelectedItem, getSelectedObjects, getUI, getUIClassID, hidePopup, insertItemAt, intervalAdded, intervalRemoved, isEditable, isLightWeightPopupEnabled, isPopupVisible, processKeyEvent, removeActionListener, removeAllItems, removeItem, removeItemAt, removeItemListener, removePopupMenuListener, selectWithKeyChar, setAction, setActionCommand, setEditable, setEditor, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setModel, 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, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, 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, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CMComboBoxJ

public CMComboBoxJ()
Insert the method's description here. Creation date: (12/18/99 11:32:35 AM)


CMComboBoxJ

public CMComboBoxJ(Object[] items)
CMComboBox constructor comment.

Parameters:
items - java.lang.Object[]

CMComboBoxJ

public CMComboBoxJ(Vector items)
CMComboBox constructor comment.

Parameters:
items - java.util.Vector

CMComboBoxJ

public CMComboBoxJ(ComboBoxModel aModel)
CMComboBox constructor comment.

Parameters:
aModel - javax.swing.ComboBoxModel
Method Detail

addBusinessObject

public void addBusinessObject(Object obj)
Adds a business object into the business object vector Creation date: (8/8/00 12:11:03 PM)

Parameters:
obj - java.lang.Object

addItem

public final void addItem(Object item)
Translate the items if it is a String and add it to the ComboBox. Also record the original strings (before translation) in case they need to be returned.

Overrides:
addItem in class JComboBox

addItemDirectly

public void addItemDirectly(Object item)
Add an item to the ComboBox with NO translation! Record it as the translated and original!


blink

public void blink(int times,
                  Color blinkColor)
Makes the combo box blink


contains

public boolean contains(Object item)
Check to see if this combo box contains the parameter Creation date: (8/7/2003 8:58:48 PM)


getApplicable

public boolean getApplicable()
adds a bit more functionality than enabled alone


getBusinessObjects

public List getBusinessObjects()
Return a Vector of businessObjects


getEnabled

public boolean getEnabled()
adds a bit more functionality than enabled alone


getForceUpperCase

public boolean getForceUpperCase()
gets the upper case boolean value

Returns:
boolean

getGetterMethod

public String getGetterMethod()
Gets the getterMethod String. This method is used to query the businessObjects for a displayable String.

Returns:
The getterMethod String value.
See Also:
setGetterMethod(java.lang.String)

getItems

public List getItems()
Gets the Items in a List of Strings that has been translated.

Returns:
the Vector of Strings that has been translated.

getOriginalStrings

public List getOriginalStrings()
Return a List of Strings that are the pre-translated Strings displayed in this component.


getSelectedBusinessObject

public Object getSelectedBusinessObject()
Return a businessObject that is being selected from the ComboBox Returns -1 if nothing was selected.


getSelectedId

public String getSelectedId()
Should use getSelectedOriginalString(). This remains for compatability.


getSelectedOriginalString

public String getSelectedOriginalString()
Return the original (pre - translation) string that is currently being selected.


getTableCellRendererComponent

public Component getTableCellRendererComponent(JTable table,
                                               Object obj,
                                               boolean isSelected,
                                               boolean hasFocus,
                                               int row,
                                               int column)
This ComboBox can act as a TableCellRenderer,

Specified by:
getTableCellRendererComponent in interface TableCellRenderer

isAllowDuplicates

public boolean isAllowDuplicates()
This will enforce whether this combo box allows duplicate entries This checks to see if one value equals another. if allowDuplicates = false, then you can if you to add an item that is already in the combobox, it fails (does not get added) Creation date: (8/7/2003 8:09:42 PM)

Returns:
boolean

isAlphabeticalSortRequired

public boolean isAlphabeticalSortRequired()
isAlphabeticalSortRequired method this method returns whether or not the BusinessObjects should be sorted in alphabetical order


isNoneInList

public boolean isNoneInList()
isNoneInList tells whether or not *NONE appears at the top of the list

Returns:
boolean

main

public static void main(String[] args)
main entrypoint - starts the part when it is run as an application

Parameters:
args - java.lang.String[]

removeBusinessObject

public void removeBusinessObject(Object obj)
Removes a business object from the business object vector Creation date: (8/8/00 12:11:03 PM)

Parameters:
obj - java.lang.Object

selectedItemChanged

public void selectedItemChanged()
Need to override to trigger the "selectedBusinessObject" property change

Overrides:
selectedItemChanged in class JComboBox

setAllowDuplicates

public void setAllowDuplicates(boolean newAllowDuplicates)
This will enforce whether this combo box allows duplicate entries This checks to see if one value equals another. if allowDuplicates = false, then you can if you to add an item that is already in the combobox, it fails (does not get added) Creation date: (8/7/2003 8:09:42 PM)

Parameters:
newAllowDuplicates - boolean

setAlphabeticalSortRequired

public void setAlphabeticalSortRequired(boolean value)
setAlphabeticalSortRequired method sets whether or not the BusinessObjects should be sorted.


setApplicable

public void setApplicable(boolean e)
adds a bit more functionality than enabled alone


setBusinessObjects

public final void setBusinessObjects(List businessObjects)
Set a List of business objects into the JComboBox. All objects are assumed to be of the same Class. The method depends on having the getter method set. The getter method is used to dynamically query the business objects and return a string to be used in the JComboBox.


setEnabled

public void setEnabled(boolean e)
override the super method to do a bit more

Overrides:
setEnabled in class JComboBox

setForceUpperCase

public void setForceUpperCase(boolean uc)
Sets the upper case boolean


setGetterMethod

public void setGetterMethod(String getterMethod)
Set a methodName to be used to query a business objects for a String that will be used as the items within a JComboBox. This methodName must match a method in the business object class. It does not need the () at the end. For example: Consider the need to select from a list of ExtractField objects, this CMComboBoxJ would be set as follows. aCMComboxBoxJ.setGetterMethod("getName"); aCMComboxBoxJ.setBusinessObjects(someVectorOfExtractFields);


setItems

public void setItems(List newItems)
Translate the Vector of Strings and then set the translated Strings in the component.


setItemsDirectly

public void setItemsDirectly(List newTranslation)
Add a List of Strings to the ComboBox directly. Assumes translation has already been done or is not needed.


setNoneInList

public void setNoneInList(boolean value)
setNoneInList sets whether or not *NONE is an option in the list

Parameters:
value - boolean

setSelectedBusinessObject

public void setSelectedBusinessObject(Object selectedBusinessObject)
Sets the selected item and handles nulls too.


setSelectedId

public void setSelectedId(String selectedId)
Should use setSelectedOriginalString. Leave here for compatability


setSelectedOriginalString

public void setSelectedOriginalString(String originalString)
Set the comboBox's selected index to the position occupied by the originalString


setTranslation

public void setTranslation(List newTranslation)
Should use setItemsDirectly() instead of this method! Sets the Vector of Strings as the items to display in this component.