Diamond Control Suite 3.0

diamondedge.swing
Class DsComboBox

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 diamondedge.swing.DsComboBox
All Implemented Interfaces:
DsConstants, ActionListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, ListDataListener, SwingConstants

public class DsComboBox
extends JComboBox
implements DsConstants

DsComboBox is a multi-column ComboBox which displays a collection of objects. Each object is represented by a DsListItem object which holds all of the information for the object being displayed including a list of DsListCell objects for each column. The items can be created in a number of different ways. One way is to call the addItem method. Another way is to use the addItems to add an array or List of objects. If the object added implements the DsListObject interface then it is used to fill in the other properties of the DsListItem such as the icons.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComboBox
JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  IconList iconlist
           
 
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 diamondedge.swing.DsConstants
ACCOUNTING, ALL, ASCENDING, ASCENDING_CASE, BORDER_BOTTOM, BORDER_LEFT, BORDER_NONE, BORDER_OUTLINE, BORDER_RIGHT, BORDER_TOP, CROSS_LINES, DASH, DASH_DOT, DASH_DOT_DOT, DEFAULT, DESCENDING, DESCENDING_CASE, DIAGONAL_CROSS_LINES, DOT, DOUBLE, DOUBLE_LINE, DOWNWARD_DIAGONAL_LINES, ETCHED, ETCHED_RAISED, FALSE, FIND_ALL, FIND_EQUALS, FIND_GT, FIND_GTE, FIND_LT, FIND_LTE, FIND_NE, FIND_PREFIX, FIND_REGEX, FIND_STRING, FIRST, FLAT, GRID_DASH, GRID_DASH_DOT, GRID_DASH_DOT_DOT, GRID_DOT, GRID_LINE, HIGHLIGHT_SELECTION_ALWAYS, HIGHLIGHT_SELECTION_NEVER, HIGHLIGHT_SELECTION_WITH_FOCUS, HORIZONTAL_LINES, LOWERED, LOWERED_LIGHT, NONE, RAISED, RAISED_LIGHT, SELECT_CELL, SELECT_NONE, SELECT_ROW, SINGLE, SINGLE_LINE, SOLID, STRETCH, TILE, TRANSPARENT, TRUE, UPWARD_DIAGONAL_LINES, VERTICAL_LINES
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DsComboBox()
           
 
Method Summary
 TableColumn addColumn()
           
 TableColumn addColumn(String columnName, String id)
           
 DsListItem addItem()
          Appends a DsListItem object to the list.
 DsListItem addItem(int index, String key, Object text, Object smallIcon)
          Adds a DsListItem object to the list.
 void addItem(List values)
          Adds an item and loads the data for multiple cells into that item.
 void addItem(Object obj)
          Loads the data from an object into the List.
 DsListItem addItem(Object[] values)
          Adds an item and loads the data for multiple cells into that item.
 void addItems(List objects)
          Loads the data from multiple objects into the List.
 void addItems(Object[] objects)
          Loads the data from multiple objects into the List.
 int calculateTotalListWidth()
          Returns the total width of the columns.
 void clear()
          Removes all items in the list.
 void configureEditor(ComboBoxEditor editor, Object item)
           
protected  DsListItem createListItem()
          Creates a new DsListItem.
 void doLayout()
           
 int findItem(String str, int col, int startRow, boolean partial)
          Finds the row index of an item in the list using a case insensitive string comparison.
 boolean getAutoExpand()
          Returns a value to specify whether the text box portion of a combo box automatically fills as you type with a value from the combo box list that matches the characters you enter.
 int getBoundColumn()
          Determines the column used as the value for the selection.
 TableColumn getColumn(int index)
           
 TableColumn getColumn(String columnId)
           
 int getColumnCount()
          Determines the total number of columns.
 DsCellProperties getColumnProperties(int col)
          Returns the default cell containing the default properties for the column.
 int getColumnWidth(int index)
          Determines the width of the specified column in pixels.
 IconList getIconList()
          Returns the IconList object to be used for the icons displayed in the DsComboBox.
 DsListItem getItem(int index)
          Returns a specific item in the list by position.
 DsListItem getItem(Object indexOrKey)
          Returns a specific item in the list by position (Number) or by key (String).
 DsListItem getItem(String key)
          Returns a specific item in the list by key.
 boolean getLimitToList()
          Returns whether a combo box's values are limited to the listed items.
 int getListWidth()
          Determines the width of the drop-down list.
 String getRowValueList()
          Returns the text used to initialize each cell in the list.
 Dimension getSize()
           
 String getText()
          Returns the string displayed in the text area (editor).
 String getTextAt(int row, int col)
          Returns the text (contents formatted as a string) for the cell at the given row and column.
 int getTextColumn()
          Determines the column used as the value for the Text.
 Object getValue()
          Returns the value for the BoundColumn of the item selected in the drop-down list or the text in the editor if no item was selected.
 Object getValueAt(int row, int column)
          Returns the cell value at row and column.
 void refresh()
          Reloads data from the original DsListObjects.
 void removeItem(int index)
          Removes a item from the list
 void setAutoExpand(boolean val)
          Sets a value to specify whether the text box portion of a combo box automatically fills as you type with a value from the combo box list that matches the characters you enter.
 void setBackground(Color c)
           
 void setBoundColumn(int val)
          Determines the column used as the value for the selection.
 void setColumnCount(int val)
          Determines the total number of columns.
 void setColumnHorizontalAlignment(int column, int align)
          Sets the horizontal alignment of the text in the column header.
 void setColumnWidth(int index, int val)
           
 void setColumnWidth(String columnId, int val)
           
 int setColumnWidthsToFit(int columnMargin)
          Returns the width of all columns and sets each column width to the size needed to fit the data in cells in that column.
 void setForeground(Color c)
           
 void setIconList(IconList i)
          Sets the IconList object to be used for the icons displayed in the DsComboBox.
 void setLimitToList(boolean val)
          Sets a value to specify whether a combo box's values are limited to the listed items.
 void setListWidth(int val)
          Determines the width of the drop-down list.
 void setRowValueList(String newValues)
          Sets the text in each cell in the list with each string being separated by a ;.
 void setShowGrid(boolean showVerticalLine, boolean showHorizontalLine)
          Sets whether the grid lines should be drawn between cells.
 void setText(String text)
          Sets the string displayed in the text area (editor).
 void setTextColumn(int val)
          Determines the column used as the value for the Text property which is diplayed in the text area of the ComboBox.
 void setValue(Object value)
          Selects the item whose value for the BoundColumn is equal to the specified value argument.
 void setValueAt(Object value, int row, int col)
          Sets the value for the cell in the model at row and column.
 void setValues(Object[] values)
          Loads the cell values from an array of values.
 void setValues(Object[][] values)
          Loads the cell values from an array of values.
 void setValues(TableModel table)
          Loads the cell values from an array of values.
 void updateUI()
           
 
Methods inherited from class javax.swing.JComboBox
actionPerformed, actionPropertyChanged, addActionListener, addItemListener, addPopupMenuListener, 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, setModel, setPopupVisible, setPrototypeDisplayValue, setRenderer, setSelectedIndex, setSelectedItem, setUI, showPopup
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, 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, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

iconlist

protected IconList iconlist
Constructor Detail

DsComboBox

public DsComboBox()
Method Detail

updateUI

public void updateUI()
Overrides:
updateUI in class JComboBox

setForeground

public void setForeground(Color c)
Overrides:
setForeground in class JComponent

setBackground

public void setBackground(Color c)
Overrides:
setBackground in class JComponent

getSize

public Dimension getSize()
Overrides:
getSize in class Component

doLayout

public void doLayout()
Overrides:
doLayout in class Container

getListWidth

public int getListWidth()
Determines the width of the drop-down list.


setListWidth

public void setListWidth(int val)
Determines the width of the drop-down list.


getBoundColumn

public int getBoundColumn()
Determines the column used as the value for the selection.

See Also:
getValue()

setBoundColumn

public void setBoundColumn(int val)
Determines the column used as the value for the selection.

See Also:
getValue()

getTextColumn

public int getTextColumn()
Determines the column used as the value for the Text.

See Also:
getText()

setTextColumn

public void setTextColumn(int val)
Determines the column used as the value for the Text property which is diplayed in the text area of the ComboBox.

See Also:
getText()

getText

public String getText()
Returns the string displayed in the text area (editor).


setText

public void setText(String text)
Sets the string displayed in the text area (editor).


getValue

public Object getValue()
Returns the value for the BoundColumn of the item selected in the drop-down list or the text in the editor if no item was selected. If the BoundColumn is less than zero then the SelectedIndex is used as the bound value.


setValue

public void setValue(Object value)
Selects the item whose value for the BoundColumn is equal to the specified value argument. If no match is made then the text editor is set to the value. If the BoundColumn is less than zero then the SelectedIndex is set to be the specified value.


getLimitToList

public boolean getLimitToList()
Returns whether a combo box's values are limited to the listed items.


setLimitToList

public void setLimitToList(boolean val)
Sets a value to specify whether a combo box's values are limited to the listed items. Text cannot be entered which does not exist in the list. If the focus is lost without completing a valid entry then it will be removed.


getAutoExpand

public boolean getAutoExpand()
Returns a value to specify whether the text box portion of a combo box automatically fills as you type with a value from the combo box list that matches the characters you enter.


setAutoExpand

public void setAutoExpand(boolean val)
Sets a value to specify whether the text box portion of a combo box automatically fills as you type with a value from the combo box list that matches the characters you enter.


setShowGrid

public void setShowGrid(boolean showVerticalLine,
                        boolean showHorizontalLine)
Sets whether the grid lines should be drawn between cells.


getIconList

public IconList getIconList()
Returns the IconList object to be used for the icons displayed in the DsComboBox.

See Also:
DsListItem.getSmallIcon(IconList)

setIconList

public void setIconList(IconList i)
Sets the IconList object to be used for the icons displayed in the DsComboBox. This allow an index or key to be stored in the DsListItem which then is used to get the icon out of this IconList based on that index/key.

See Also:
DsListItem.getSmallIcon(IconList)

getValueAt

public Object getValueAt(int row,
                         int column)
Returns the cell value at row and column.

Note: The column is specified in the model's column order.

Returns:
the Object at the specified row and column

setValueAt

public void setValueAt(Object value,
                       int row,
                       int col)
Sets the value for the cell in the model at row and column.


getTextAt

public String getTextAt(int row,
                        int col)
Returns the text (contents formatted as a string) for the cell at the given row and column.


setColumnWidthsToFit

public int setColumnWidthsToFit(int columnMargin)
Returns the width of all columns and sets each column width to the size needed to fit the data in cells in that column.

Parameters:
columnMargin - extra amount to add to each column width

calculateTotalListWidth

public int calculateTotalListWidth()
Returns the total width of the columns.


addItem

public DsListItem addItem()
Appends a DsListItem object to the list.


addItem

public DsListItem addItem(int index,
                          String key,
                          Object text,
                          Object smallIcon)
Adds a DsListItem object to the list.

Parameters:
index - Row position to add the item
key - Unique string that can be used to locate this item
text - String that will displayed as the label and column 0
smallIcon - index (Integer) or key (String) of an icon in the associated IconList control. Can also be an Icon or Image. Used in all views except LARGE_ICON view.
See Also:
setIconList(diamondedge.swing.IconList)

addItem

public void addItem(Object obj)
Loads the data from an object into the List. If the object is an instanceof DsListObject then all columns, icons, etc are also loaded.

Overrides:
addItem in class JComboBox

addItem

public DsListItem addItem(Object[] values)
Adds an item and loads the data for multiple cells into that item.


addItem

public void addItem(List values)
Adds an item and loads the data for multiple cells into that item.


removeItem

public void removeItem(int index)
Removes a item from the list

Parameters:
index - Row position of item to remove

createListItem

protected DsListItem createListItem()
Creates a new DsListItem. Subclasses can override this to return an instance of a subclass of DsListItem


getItem

public DsListItem getItem(int index)
Returns a specific item in the list by position.

Parameters:
index - Row position of item to remove

getItem

public DsListItem getItem(String key)
Returns a specific item in the list by key.


getItem

public DsListItem getItem(Object indexOrKey)
Returns a specific item in the list by position (Number) or by key (String).


clear

public void clear()
Removes all items in the list. Same as removeAllItems method.

See Also:
JComboBox.removeAllItems()

addItems

public void addItems(Object[] objects)
Loads the data from multiple objects into the List. If the object is an instanceof DsListObject then all columns, icons, etc are also loaded. Otherwise, the return from toString() for each object will be displayed in the list. The object is stored in the Data property for the DsListItem.


addItems

public void addItems(List objects)
Loads the data from multiple objects into the List. If the object is an instanceof DsListObject then all columns, icons, etc are also loaded. Otherwise, the return from toString() for each object will be displayed in the list. The object is stored in the Data property for the DsListItem.


setValues

public void setValues(TableModel table)
Loads the cell values from an array of values.


setValues

public void setValues(Object[][] values)
Loads the cell values from an array of values.


setValues

public void setValues(Object[] values)
Loads the cell values from an array of values. Cells will be filled row by row with one value for each column in the row.


getRowValueList

public String getRowValueList()
Returns the text used to initialize each cell in the list.


setRowValueList

public void setRowValueList(String newValues)
Sets the text in each cell in the list with each string being separated by a ;. Cells will be filled row by row with one value for each column in the row. If the column headers are visible then the first row of values will be the titles for the column headers.


refresh

public void refresh()
Reloads data from the original DsListObjects. Useful if you know that the data has changed and you want to update the display.


getColumnCount

public int getColumnCount()
Determines the total number of columns.


setColumnCount

public void setColumnCount(int val)
Determines the total number of columns.


getColumnProperties

public DsCellProperties getColumnProperties(int col)
Returns the default cell containing the default properties for the column.


setColumnHorizontalAlignment

public void setColumnHorizontalAlignment(int column,
                                         int align)
Sets the horizontal alignment of the text in the column header. Also sets the default horizontal alignment of text in the cells for the column. Valid values are:


getColumn

public TableColumn getColumn(int index)

getColumn

public TableColumn getColumn(String columnId)

getColumnWidth

public int getColumnWidth(int index)
Determines the width of the specified column in pixels.


setColumnWidth

public void setColumnWidth(int index,
                           int val)

setColumnWidth

public void setColumnWidth(String columnId,
                           int val)

addColumn

public TableColumn addColumn()

addColumn

public TableColumn addColumn(String columnName,
                             String id)

configureEditor

public void configureEditor(ComboBoxEditor editor,
                            Object item)
Overrides:
configureEditor in class JComboBox

findItem

public int findItem(String str,
                    int col,
                    int startRow,
                    boolean partial)
Finds the row index of an item in the list using a case insensitive string comparison.

Parameters:
str - String to find in the List
col - which column to search
startRow - starting item to begin searching
partial - match the beginning of the string or the whole string

Diamond Control Suite 3.0

Diamond Edge and Diamond Control Suite are trademarks or registered trademarks of Diamond Edge, Inc. Copyright 1999-2005 Diamond Edge, Inc. All Rights Reserved.