SilverStream
Application Server 3.5

com.sssw.rt.jform
Class AgcJComboBox

java.lang.Object
 |
 +--java.awt.Component
       |
       +--java.awt.Container
             |
             +--javax.swing.JComponent
                   |
                   +--javax.swing.JComboBox
                         |
                         +--com.sssw.rt.jform.AgcJComboBox
All Implemented Interfaces:
Accessible, ActionListener, AgiHelpInfo, AgiRowSetManager, EventListener, ImageObserver, ItemSelectable, ListDataListener, MenuContainer, Serializable

public class AgcJComboBox
extends JComboBox
implements AgiRowSetManager, AgiHelpInfo

A lightweight component that displays a list of values in a dropdown list. The currently selected value is displayed in an input field where it can be edited, if editing is allowed. The AgcJComboBox control is a data-bound list control.

When the control is bound to a database column via the Data Column property, the value in the database sets the initially selected item in the list. If the user makes a different selection, that item becomes the value associated with the current row. Each list item can have a display value and an associated storage value. The display value is a String, but the storage value can be any Object. If there is no separate display value, the Object is converted to a String for display. The storage value is the value sent to the database when you call updateRows() for the form.

In addition to being data-bound, the control is a data-loaded control; meaning a database table or other data source can provide the list items. You can use methods of AgiRowSetManager to navigate the list. However, changes to the list items do not affect the underlying data; therefore, calling updateRows() is not allowed. If you call it for the control, updateRows() throws AgoUnsupportedOperationException.

In the Form Designer's Property Inspector, you can specify that the list values be loaded from a table, or you can provide static lists of display and storage values.

For the data model, AgcJComboBox uses the DefaultComboBoxModel. However, you seldom need to work directly with the model. AgcJComboBox and its ancestor JComboBox provide methods that add and remove list items from the model.

Properties:
Automatic Query, Choices, Control Type, Data Column, Display Value, Distinct, Editable, Enabled, Font Name, Font Size, Font Style, Height, Help Page, Left, Limit Rows, Load Choices, Maximum Rows, Name, Order By, Storage Value, Table, Tool Tip, Top, Values, Visible, Where Clause, Width
Events:
focusGained, focusLost, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, validationFailed, validationTest, valueChanged
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JComboBox
JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager
 
Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
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
 
Constructor Summary
AgcJComboBox()
          Initializes a AgcJComboBox control with an empty list.
AgcJComboBox(ComboBoxModel m)
          Initializes the control with list items from a DefaultComboBoxModel.
AgcJComboBox(Object[] items)
          Initializes the control with a DefaultComboBoxModel whose values are specified in the items array.
AgcJComboBox(Vector items)
          Initializes the control with a DefaultComboBoxModel whose values are specified in the items Vector.
 
Method Summary
 void addItem(String title, Object value)
          Appends an item to the list, specifying both the display text and the list item's value.
 Object getItemValue(int index)
          Gets the text of the item at the specified index.
 Object getValue()
          Gets the storage value of the selected item, which is the value that is sent to the database.
 void insertItemAt(String title, Object value, int index)
          Adds an item at the specified index in the list, specifying both the display text and the list item's value.
 void loadFromRowCursor(AgiRowCursor rc, int displaycol, int valuecol)
          Creates list items from an AgiRowCursor data source.
 void setValue(Object value)
          Selects the item whose value matches the specified value.
 
Methods inherited from class javax.swing.JComboBox
actionPerformed, addActionListener, addItem, addItemListener, configureEditor, contentsChanged, createDefaultKeySelectionManager, fireActionEvent, fireItemStateChanged, getAccessibleContext, 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, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, processComponentKeyEvent, processFocusEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, 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, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, 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, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, 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
 
Methods implemented from interface com.sssw.rt.form.AgiHelpInfo
getHelpInfo, setHelpInfo
 
Methods implemented from interface com.sssw.rt.util.AgiRowSetManager
clearRows, haveRowsChanged, query, query, refreshRows, updateRows
 

Constructor Detail

AgcJComboBox

public AgcJComboBox()
Initializes a AgcJComboBox control with an empty list.

AgcJComboBox

public AgcJComboBox(ComboBoxModel m)
Initializes the control with list items from a DefaultComboBoxModel.
Parameters:
m - a DefaultComboBoxModel that has been initialized with list items

AgcJComboBox

public AgcJComboBox(Object[] items)
Initializes the control with a DefaultComboBoxModel whose values are specified in the items array.
Parameters:
items - an array of Objects where each element becomes an item in the list

AgcJComboBox

public AgcJComboBox(Vector items)
Initializes the control with a DefaultComboBoxModel whose values are specified in the items Vector.
Parameters:
items - a Vector object whose elements become the displayed list
Method Detail

addItem

public void addItem(String title,
                    Object value)
Appends an item to the list, specifying both the display text and the list item's value.
Parameters:
title - a String specifying the item's display value
value - an Object, which is the item's value, which may be null
Usage:
This method works only if the AgcJComboBox uses the default data model. AgcJComboBox uses the default data model when created with the empty constructor and no other model has been set.
See Also:
AgcJComboBox.insertItemAt(String, Object, int), AgcJComboBox.loadFromRowCursor(AgiRowCursor, int, int)

insertItemAt

public void insertItemAt(String title,
                         Object value,
                         int index)
Adds an item at the specified index in the list, specifying both the display text and the list item's value.
Parameters:
title - a String specifying the item's display value
value - an Object, which is the item's value, which may be null
index - an int specifying the position for the Object in the list. Index must be between 0 and the size of the list.
Usage:
This method works only if the AgcJComboBox uses the default data model. AgcJComboBox uses the default data model when created with the empty constructor and no other model has been set.
See Also:
AgcJComboBox.addItem(String, Object), AgcJComboBox.loadFromRowCursor(AgiRowCursor, int, int)

getItemValue

public Object getItemValue(int index)
Gets the text of the item at the specified index.
Parameters:
index - an int specifying the item's position in the list. Index must be between 0 and the size of the list.
Returns:
a String that is the display value for the item.
See Also:
AgcJComboBox.getValue()

getValue

public Object getValue()
Gets the storage value of the selected item, which is the value that is sent to the database.
Returns:
an Object, which is the item's value.
See Also:
AgcJComboBox.setValue(Object)

setValue

public void setValue(Object value)
Selects the item whose value matches the specified value.
Parameters:
value - an Object representing the item you want to select
See Also:
AgcJComboBox.getValue()

loadFromRowCursor

public void loadFromRowCursor(AgiRowCursor rc,
                              int displaycol,
                              int valuecol)
                       throws AgoSecurityException,
                              AgoTransientSystemException,
                              AgoUnrecoverableSystemException
Creates list items from an AgiRowCursor data source. Each row becomes an item. This is similar to specifying in the Form Designer that you want to load list values from a table.
Parameters:
rc - the AgiRowCursor object whose data you want to be the list
displaycol - an int specifying the number of a column in the AgiRowCursor object whose values will be the display values for the list items
valuecol - an int specifying the number of a column in the AgiRowCursor object whose values will be the storage values for the list items
See Also:
AgcJComboBox.addItem(String, Object), AgcJComboBox.insertItemAt(String, Object, int)

SilverStream
Application Server 3.5