com.sas.swing.visuals
Class ComboBox

com.sas.swing.visuals.ComboBox
All Implemented Interfaces:
com.sas.swing.visuals.ValueInterface, 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
Direct Known Subclasses:
com.sas.swing.visuals.ComponentComboBox

public class ComboBox
implements com.sas.swing.visuals.ValueInterface

This class subclasses JComboBox to provide general extensions and corrections to behavior that are useful to applications at SAS.

Some keystrokes are currently missing from JComboBox, and so this class processes them appropriately. Specifically, spacebar opens/closes the popup list. Down arrow opens the popup list if necessary. Alt + down arrow opens the popup list while Alt + up arrow closes the popup list.

This class also includes an overloaded addItem method that takes a tool tip parameter, and will display tool tips for the items in the drop-down list.

Separators are also supported as items that can be added to the combo box.

If an item is added to the combo box and it's an instance of java.awt.Window, selecting the item from the combo box will cause the window item to be launched on screen, appearing adjacent to the combo box.

This class was originally pulled from Information Map Studio (MapCenter) and was originally written by Greg Thorne. It has been relocated here and expanded for use across other applications.

See Also:
Serialized Form

Field Summary
protected  java.util.HashMap displayNameMap
           
protected  java.lang.Object previousSelection
           
static java.lang.String SEPARATOR
           
protected  java.util.HashMap toolTipMap
           
 
Constructor Summary
ComboBox()
           
ComboBox(javax.swing.ComboBoxModel aModel)
           
ComboBox(java.lang.Object[] items)
           
ComboBox(java.util.Vector items)
           
 
Method Summary
 void addItem(java.lang.Object item, java.lang.String toolTip)
          Adds an item to the item list.
protected  void alignAndShowWindow(java.awt.Window window)
           
protected  void init()
           
protected  void processComponentKeyEvent(java.awt.event.KeyEvent event)
          Overrides the processing of key events to provide additional functionality.
 

Field Detail

displayNameMap

protected java.util.HashMap displayNameMap

toolTipMap

protected java.util.HashMap toolTipMap

SEPARATOR

public static java.lang.String SEPARATOR

previousSelection

protected java.lang.Object previousSelection
Constructor Detail

ComboBox

public ComboBox()

ComboBox

public ComboBox(java.lang.Object[] items)

ComboBox

public ComboBox(java.util.Vector items)

ComboBox

public ComboBox(javax.swing.ComboBoxModel aModel)
Method Detail

init

protected void init()

alignAndShowWindow

protected void alignAndShowWindow(java.awt.Window window)

processComponentKeyEvent

protected void processComponentKeyEvent(java.awt.event.KeyEvent event)
Overrides the processing of key events to provide additional functionality.

Overrides:
processComponentKeyEvent in class javax.swing.JComponent

addItem

public void addItem(java.lang.Object item,
                    java.lang.String toolTip)
Adds an item to the item list. This method works only if the JComboBox uses a mutable data model. This overloaded method of addItem takes an additional tooltip string parameter which will be associated with the specified item.

You can specify ComboBox.SEPARATOR as the item to have a horizontal line separator appear in the list.

Parameters:
item - The item to add to the combobox.
toolTip - The item's tooltip which will appear when the user hovers over the item in the list.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.