com.nqadmin.swingSet
Class SSComboBox

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JComboBox
                  extended by com.nqadmin.swingSet.SSComboBox
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ListDataListener

public class SSComboBox
extends javax.swing.JComboBox

SSComboBox.java

SwingSet - Open Toolkit For Making Swing Controls Database-Aware

 Provides a way of displaying text corresponding to codes that are stored in
 the database. By default the codes start from zero. If you want to provide a
 different mapping for the items in the combobox then a string of integers
 containing the corresponding numeric values for each choice must be provided.

 Note that if you DO NOT want to use the default mappings, the custom
 mappings must be set before calling the bind() method to bind the
 combobox to a database column.

 Also, if changing both a sSRowSet and column name consider using the bind()
 method rather than individual setSSRowSet() and setColumName() calls. 

 e.g.
      SSComboBox combo = new SSComboBox();
      String[] options = {"111", "2222", "33333"};
      combo.setOptions(options);

      For the above items the combobox assumes that the values start from zero:
           "111" -> 0, "2222" -> 1, "33333" -> 2

      To give your own mappings  you can set the mappings separately or pass
      them along with the options:

      SSComboBox combo = new SSComboBox();
      String[] options = {"111", "2222", "33333"};
      int[] mappings = { 1,5,7 };
      combo.setOptions(options, mappings);

      // next line is assuming mysSRowSet has been initialized and my_column is a
      // column in mysSRowSet
      combo.bind(mysSRowSet,"my_column");

Version:
$Revision: 1.34 $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComboBox
javax.swing.JComboBox.KeySelectionManager
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static int EXCLUDE
          Predefined "exclude" option.
static int FEMALE
          Predefined "female" option.
static int GENDER_OPTION
          Constant indicating that combo box should display predefined gender options.
static int INCLUDE
          Predefined "include" option.
static int INCLUDE_EXCLUDE_OPTION
          Constant indicating that combo box should display predefined include/exclude options.
static int MALE
          Predefined "male" option.
static int NO
          Predefined "no" option.
static int NON_SELECTED
          Value to represent that no item has been selected in the combo box.
static int SEX_OPTION
          Deprecated.  
static int UNI_SEX
          Deprecated.  
static int UNISEX
          Predefined "unisex" option.
static int YES
          Predefined "yes" option.
static int YES_NO_OPTION
          Constant indicating that combo box should display predefined yes/no options.
 
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
SSComboBox()
          Creates an object of SSComboBox.
SSComboBox(SSTextDocument document)
          Deprecated.  
 
Method Summary
 void bind(SSRowSet _sSRowSet, java.lang.String _columnName)
          Sets the SSRowSet and column name to which the component is to be bound.
 java.lang.String getColumnName()
          Returns the column name to which the combo is bound.
 javax.swing.JComboBox getComboBox()
          Deprecated.  
 java.awt.Component getComponent()
          Deprecated.  
 int[] getMappings()
          Returns the underlying values for each of the items in the combo box (e.g.
 java.lang.String[] getOptions()
          Returns the items displayed in the combo box.
 int getPredefinedOptions()
          Returns the option code used to display predefined options in the combo box.
 int getSelectedValue()
          Returns the combo box value associated with the currently selected item.
 SSRowSet getSSRowSet()
          Returns the SSRowSet being used to get the values.
 void setColumnName(java.lang.String _columnName)
          Sets the SSRowSet column name to which the component is bound.
 void setDocument(SSTextDocument _document)
          Deprecated.  
 void setMappings(int[] _mappings)
          Sets the underlying values for each of the items in the combo box (e.g.
 void setMappingValues(int[] _mappings)
          Deprecated.  
 boolean setOption(int _option)
          Deprecated.  
 void setOption(int _options, int[] _mappings)
          Deprecated.  
 boolean setOption(java.lang.String[] _options)
          Deprecated.  
 boolean setOption(java.lang.String[] _options, int[] _mappings)
          Deprecated.  
 void setOptions(java.lang.String[] _options)
          Adds an array of strings as combo box items.
 boolean setOptions(java.lang.String[] _options, int[] _mappings)
          Sets the options to be displayed in the combo box and their corresponding values.
 boolean setPredefinedOptions(int _predefinedOptions)
          Sets the options to be displayed in the combo box based on common predefined options.
 void setSelectedValue(int _value)
          Sets the value stored in the component.
 void setSSRowSet(SSRowSet _sSRowSet)
          Sets the SSRowSet to which the component is bound.
 
Methods inherited from class javax.swing.JComboBox
actionPerformed, addActionListener, addItem, 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, setEnabled, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setModel, setPopupVisible, setPrototypeDisplayValue, setRenderer, setSelectedIndex, setSelectedItem, setUI, showPopup, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NON_SELECTED

public static final int NON_SELECTED
Value to represent that no item has been selected in the combo box.


YES_NO_OPTION

public static final int YES_NO_OPTION
Constant indicating that combo box should display predefined yes/no options.

See Also:
Constant Field Values

YES

public static final int YES
Predefined "yes" option.

See Also:
Constant Field Values

NO

public static final int NO
Predefined "no" option.

See Also:
Constant Field Values

GENDER_OPTION

public static final int GENDER_OPTION
Constant indicating that combo box should display predefined gender options.

See Also:
Constant Field Values

MALE

public static final int MALE
Predefined "male" option.

See Also:
Constant Field Values

FEMALE

public static final int FEMALE
Predefined "female" option.

See Also:
Constant Field Values

UNISEX

public static final int UNISEX
Predefined "unisex" option.

See Also:
Constant Field Values

INCLUDE_EXCLUDE_OPTION

public static final int INCLUDE_EXCLUDE_OPTION
Constant indicating that combo box should display predefined include/exclude options.

See Also:
Constant Field Values

EXCLUDE

public static final int EXCLUDE
Predefined "exclude" option.

See Also:
Constant Field Values

INCLUDE

public static final int INCLUDE
Predefined "include" option.

See Also:
Constant Field Values

SEX_OPTION

public static final int SEX_OPTION
Deprecated. 
Constant indicating that combo box should display predefined gender options.

See Also:
GENDER_OPTION, Constant Field Values

UNI_SEX

public static final int UNI_SEX
Deprecated. 
Predefined "unisex" option.

See Also:
UNISEX, Constant Field Values
Constructor Detail

SSComboBox

public SSComboBox()
Creates an object of SSComboBox.


SSComboBox

public SSComboBox(SSTextDocument document)
Deprecated. 

Creates an instance of SSComboBox and sets the text field with which the combo box will be synchronized with.

Method Detail

setSelectedValue

public void setSelectedValue(int _value)
Sets the value stored in the component. Currently not a bean property since there is no associated variable.

Parameters:
_value - value to assign to combo box

getSelectedValue

public int getSelectedValue()
Returns the combo box value associated with the currently selected item. Currently not a bean property since there is no associated variable.

Returns:
returns the value associated with the selected item OR -1 if nothing is selected.

setColumnName

public void setColumnName(java.lang.String _columnName)
Sets the SSRowSet column name to which the component is bound.

Parameters:
_columnName - column name in the SSRowSet to which the component is bound

getColumnName

public java.lang.String getColumnName()
Returns the column name to which the combo is bound.

Returns:
returns the column name to which to combo box is bound.

setSSRowSet

public void setSSRowSet(SSRowSet _sSRowSet)
Sets the SSRowSet to which the component is bound.

Parameters:
_sSRowSet - SSRowSet to which the component is bound

getSSRowSet

public SSRowSet getSSRowSet()
Returns the SSRowSet being used to get the values.

Returns:
returns the SSRowSet being used.

setMappings

public void setMappings(int[] _mappings)
Sets the underlying values for each of the items in the combo box (e.g. the values that map to the items displayed in the combo box)

Parameters:
_mappings - an array of values that correspond to those in the combo box.

getMappings

public int[] getMappings()
Returns the underlying values for each of the items in the combo box (e.g. the values that map to the items displayed in the combo box)

Returns:
returns the underlying values for each of the items in the combo box

setOptions

public void setOptions(java.lang.String[] _options)
Adds an array of strings as combo box items.

Parameters:
_options - the list of options that you want to appear in the combo box.

getOptions

public java.lang.String[] getOptions()
Returns the items displayed in the combo box.

Returns:
returns the items displayed in the combo box

setOptions

public boolean setOptions(java.lang.String[] _options,
                          int[] _mappings)
Sets the options to be displayed in the combo box and their corresponding values.

Parameters:
_options - options to be displayed in the combo box.
_mappings - integer values that correspond to the options in the combo box.
Returns:
returns true if the options and mappings are set successfully - returns false if the size of arrays do not match or if the values could not be set

setPredefinedOptions

public boolean setPredefinedOptions(int _predefinedOptions)
Sets the options to be displayed in the combo box based on common predefined options.

Parameters:
_predefinedOptions - predefined options to be displayed in the combo box.

getPredefinedOptions

public int getPredefinedOptions()
Returns the option code used to display predefined options in the combo box.

Returns:
returns the predefined option code

bind

public void bind(SSRowSet _sSRowSet,
                 java.lang.String _columnName)
Sets the SSRowSet and column name to which the component is to be bound.

Parameters:
_sSRowSet - datasource to be used.
_columnName - Name of the column to which this check box should be bound

setDocument

public void setDocument(SSTextDocument _document)
Deprecated. 

Sets the document to which the combo box will be bound to. Changes to this will immediately reflect in the combo box.

Parameters:
_document - text document to which the combo box has to be bound
See Also:
bind(com.nqadmin.swingSet.datasources.SSRowSet, java.lang.String)

getComboBox

public javax.swing.JComboBox getComboBox()
Deprecated. 

returns the combo box that has to be displayed on screen.

Returns:
returns the combo box that displays the items.

getComponent

public java.awt.Component getComponent()
Deprecated. 

Returns the combo box to be displayed on the screen.

Returns:
returns the combo box that displays the items.

setOption

public boolean setOption(java.lang.String[] _options)
Deprecated. 

Adds an array of strings as combo box items.

Parameters:
_options - the list of options that you want to appear in the combo box.
Returns:
returns true if the options and mappings are set successfully - returns false if the size of arrays do not match or if the values could not be set
See Also:
setOptions(java.lang.String[])

setOption

public boolean setOption(java.lang.String[] _options,
                         int[] _mappings)
Deprecated. 

Sets the options to be displayed in the combo box and their corresponding values.

Parameters:
_options - options to be displayed in the combo box.
_mappings - integer values that correspond to the options in the combo box.
Returns:
returns true if the options and mappings are set successfully - returns false if the size of arrays do not match or if the values could not be set
See Also:
setOptions(java.lang.String[])

setOption

public void setOption(int _options,
                      int[] _mappings)
               throws java.beans.PropertyVetoException
Deprecated. 

Sets the options to be displayed in the combo box and their corresponding values.

Parameters:
_options - predefined options to be displayed in the combo box.
_mappings - integer values that correspond to the options in the combo box.
Throws:
java.beans.PropertyVetoException
See Also:
setPredefinedOptions(int), setMappings(int[])

setOption

public boolean setOption(int _option)
Deprecated. 

Sets the options to be displayed in the combo box based on common predefined options.

Parameters:
_option - predefined options to be displayed in the combo box.
See Also:
setPredefinedOptions(int)

setMappingValues

public void setMappingValues(int[] _mappings)
Deprecated. 

Sets the underlying values for each of the items in the combo box (e.g. the values that map to the items displayed in the combo box)

Parameters:
_mappings - an array of values that correspond to those in the combo box.
See Also:
setMappings(int[])