net.xoetrope.swing
Class XComboBox

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 net.xoetrope.swing.XComboBox
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, XAttributedComponent, XListHolder

public class XComboBox
extends javax.swing.JComboBox
implements XListHolder, XAttributedComponent

A wrapper for the Swing JComboBox class

Copyright (c) Xoetrope Ltd., 1998-2003
License: see license.txt

See Also:
Serialized Form

Nested Class Summary
 class XComboBox.SystemSelectionManager
          A search manager for finding list entries as the user types a value
 
Nested classes/interfaces inherited from class javax.swing.JComboBox
javax.swing.JComboBox.AccessibleJComboBox, javax.swing.JComboBox.KeySelectionManager
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, 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
XComboBox()
          Create a new combo
 
Method Summary
 void add(java.lang.String s)
          Add an item to the list
 void addItem(java.lang.String s)
          Add an item to the drop down list
 java.lang.Object getSelectedObject()
          Get the selected object
 java.lang.Object[] getSelectedObjects()
          Get the selected objects
 int getSelectionMode()
          Get the list selection mode.
 boolean isSearchable()
          Is the current key selectionmanager searchable
 void removeAll()
          Remove everythibg from the list
 void select(int i)
          Select an item in the list
 void select(java.lang.Object o)
          Select an item in the list
 int setAttribute(java.lang.String attribName, java.lang.Object attribValue)
          Set one or more attributes of the component.
 void setBackground(java.awt.Color c)
          Set the background color for the edit field
 void setDefaultSelection()
          Set the list to its default selection state
 void setForeground(java.awt.Color c)
          Set the foreground color for the edit field
 void setRenderer(javax.swing.ListCellRenderer renderer)
          Set the list cell renderer, preserving the foreground and background colors in the process
 void setSearchable(boolean doSearch)
          Set the combo as searchable
 void setSelectedObject(java.lang.Object o)
          Get the selected object
 void setSelectedObjects(java.lang.Object[] values)
          Set the selected objects
 
Methods inherited from class javax.swing.JComboBox
actionPerformed, actionPropertyChanged, 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, 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, setSelectedIndex, setSelectedItem, setUI, showPopup, updateUI
 
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, 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, processContainerEvent, processEvent, remove, remove, 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, 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, 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
 
Methods inherited from interface net.xoetrope.xui.XListHolder
getItemCount, getSelectedIndex
 

Constructor Detail

XComboBox

public XComboBox()
Create a new combo

Method Detail

setDefaultSelection

public void setDefaultSelection()
Set the list to its default selection state

Specified by:
setDefaultSelection in interface XListHolder

addItem

public void addItem(java.lang.String s)
Add an item to the drop down list

Specified by:
addItem in interface XListHolder
Parameters:
s - the new list item

select

public void select(int i)
Select an item in the list

Specified by:
select in interface XListHolder
Parameters:
i - the selected item's index

select

public void select(java.lang.Object o)
Select an item in the list

Specified by:
select in interface XListHolder
Parameters:
o - the item to select

getSelectedObject

public java.lang.Object getSelectedObject()
Get the selected object

Specified by:
getSelectedObject in interface XListHolder
Returns:
the selection

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Get the selected objects

Specified by:
getSelectedObjects in interface java.awt.ItemSelectable
Specified by:
getSelectedObjects in interface XListHolder
Overrides:
getSelectedObjects in class javax.swing.JComboBox
Returns:
the selected object

setSelectedObject

public void setSelectedObject(java.lang.Object o)
Get the selected object

Specified by:
setSelectedObject in interface XListHolder
Parameters:
o - the selected object

setSelectedObjects

public void setSelectedObjects(java.lang.Object[] values)
Set the selected objects

Specified by:
setSelectedObjects in interface XListHolder
Parameters:
values - the selected object

add

public void add(java.lang.String s)
Add an item to the list

Parameters:
s - the new item

removeAll

public void removeAll()
Remove everythibg from the list

Specified by:
removeAll in interface XListHolder
Overrides:
removeAll in class java.awt.Container

setBackground

public void setBackground(java.awt.Color c)
Set the background color for the edit field

Overrides:
setBackground in class javax.swing.JComponent
Parameters:
c - the color

setForeground

public void setForeground(java.awt.Color c)
Set the foreground color for the edit field

Overrides:
setForeground in class javax.swing.JComponent
Parameters:
c - the color

setRenderer

public void setRenderer(javax.swing.ListCellRenderer renderer)
Set the list cell renderer, preserving the foreground and background colors in the process

Overrides:
setRenderer in class javax.swing.JComboBox
Parameters:
renderer - the new renderer.

setSearchable

public void setSearchable(boolean doSearch)
Set the combo as searchable

Parameters:
doSearch - true to search using keys as they are typed to form a search word, or false to use only the key as the first character of the search - match only the first letter.

isSearchable

public boolean isSearchable()
Is the current key selectionmanager searchable

Returns:
true if a complex search is performed, false if only a single letter match is performed

setAttribute

public int setAttribute(java.lang.String attribName,
                        java.lang.Object attribValue)
Set one or more attributes of the component.
  1. editable, value=true to allow edits
  2. search, value=true to search the list as the user types
  3. pause, the value in milliseconds of the delay between keystrokes before the search is dismissed (the default 1000 milliseconds). The pause attribute implies the search attribute

Specified by:
setAttribute in interface XAttributedComponent
Parameters:
attribName - the name of the attribute
attribValue - the value of the attribute
Returns:
0 for success, non zero for failure or to require some further action

getSelectionMode

public int getSelectionMode()
Get the list selection mode. This method returns 0.

Specified by:
getSelectionMode in interface XListHolder
Returns:
  • 0=ListSelectionModel.SINGLE_SELECTION,
  • 1=ListSelectionModel.SINGLE_INTERVAL_SELECTION,
  • 2=ListSelectionModel.MULTIPLE_INTERVAL_SELECTION