com.lizardtech.djvubean.toolbar
Class ComboBox

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by com.lizardtech.djvubean.toolbar.ComboBox
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable

public class ComboBox
extends java.awt.Container
implements java.awt.ItemSelectable

This class is designed as an AWT replacement to JComboBox. The main difference between this class and the Choice class, is editable fields are supported, and better control is given to the rendering of the selection field.

Version:
$Revision: 1.4 $
Author:
Bill C. Riemers
See Also:
Serialized Form

Nested Class Summary
 
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  ToggleButton button
          The button used to activate/deactivate popup selection menu.
protected  java.awt.CardLayout cardLayout
          A CardLayout to swap between the Choice box, and the Text selection box.
protected  PopupChoice choice
          An extension of the Choice class, designed to deliver events to the ComboBox.
protected  java.lang.String customText
          The text indicating the last selected value.
protected  java.awt.Container editContainer
          The container used for the Text selection box, and the selection button.
protected  java.util.Hashtable itemMap
          A table of Objects mapped to their selection strings.
protected  java.lang.Object lastSelectedItem
          The last item selected.
protected  java.awt.TextField textField
          The text selection field, used for editing values.
 
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
 
Method Summary
 void addItem(java.lang.Object item)
          Add an Item to the selection list.
 void addItemListener(java.awt.event.ItemListener listener)
          Add an ItemListener.
 ToggleButton getButton()
          Query the toggle button used for selection.
 java.awt.TextField getEditor()
          Returns the text editor field.
 int getItemCount()
          Query the number of items registered.
 java.awt.event.ItemListener[] getItemListeners()
          Query all ItemListeners registered with this component.
 java.util.Hashtable getItemMap()
          Query the Hashtable of items.
 double getScaleFactor()
          Query the scale factor used to reduce image sizes.
 int getSelectedIndex()
          Query the index of the currently selected item.
 java.lang.Object[] getSelectedObjects()
          Query selected objects.
 void hidePopup()
          Hide the popup selection menu.
 boolean isEditable()
          Test if the ComboBox is editable.
 boolean isPopupVisible()
          Returns true if the pop-up might be currently visible.
protected  void processEvent(java.awt.AWTEvent event)
          Called to process an event.
 void processItemEvent(java.awt.event.ItemEvent event)
          Called to process an ItemEvent.
 void removeItem(java.lang.Object item)
          Remove an item from the selection list.
 void removeItemListener(java.awt.event.ItemListener listener)
          Remove an ItemListener.
 java.awt.event.ItemEvent replaceItemEvent(java.awt.event.ItemEvent event)
          Called to replace the selection string with the selection Object in an ItemEvent.
 void setBackground(java.awt.Color bgColor)
          Set the background color.
 void setEditable(boolean editable)
          Set the editability of this ComboBox
 void setEnabled(boolean enabled)
          Used to enable this ComboBox.
 void setForeground(java.awt.Color fgColor)
          Set the current foreground color.
 void setIsPopupVisible(boolean isPopupVisible)
          Set the value of the isPopupVisible.
 void setScaleFactor(double value)
          Set the scale factor used to reduce image sizes.
 void setSelectedItem(java.lang.Object item)
          Set the specified item to be selected.
 void showChoice()
           
 void showEditor()
           
 void showPopup()
          Show the item selection menu.
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, 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

cardLayout

protected final java.awt.CardLayout cardLayout
A CardLayout to swap between the Choice box, and the Text selection box.


editContainer

protected final java.awt.Container editContainer
The container used for the Text selection box, and the selection button.


itemMap

protected final java.util.Hashtable itemMap
A table of Objects mapped to their selection strings.


lastSelectedItem

protected java.lang.Object lastSelectedItem
The last item selected.


choice

protected final PopupChoice choice
An extension of the Choice class, designed to deliver events to the ComboBox.


textField

protected final java.awt.TextField textField
The text selection field, used for editing values.


customText

protected java.lang.String customText
The text indicating the last selected value.


button

protected ToggleButton button
The button used to activate/deactivate popup selection menu.

Method Detail

setBackground

public void setBackground(java.awt.Color bgColor)
Set the background color.

Overrides:
setBackground in class java.awt.Component
Parameters:
bgColor - the new background color to use.

getButton

public ToggleButton getButton()
Query the toggle button used for selection.

Returns:
the ToggleButton.

setEditable

public void setEditable(boolean editable)
Set the editability of this ComboBox

Parameters:
editable - true if this ComboBox should be editable.

isEditable

public boolean isEditable()
Test if the ComboBox is editable.

Returns:
true if the ComboBox is editable.

getEditor

public java.awt.TextField getEditor()
Returns the text editor field.

Returns:
the TextField used for editable values.

setEnabled

public void setEnabled(boolean enabled)
Used to enable this ComboBox.

Overrides:
setEnabled in class java.awt.Component
Parameters:
enabled - true if enabled.

setForeground

public void setForeground(java.awt.Color fgColor)
Set the current foreground color.

Overrides:
setForeground in class java.awt.Component
Parameters:
fgColor - the new foreground color.

setIsPopupVisible

public void setIsPopupVisible(boolean isPopupVisible)
Set the value of the isPopupVisible. This should be private, but is public due to linking restrictions with JDK 1.1.8.

Parameters:
isPopupVisible - true if the pop-up is visible.

getItemCount

public int getItemCount()
Query the number of items registered.

Returns:
the number of items registered.

getItemListeners

public java.awt.event.ItemListener[] getItemListeners()
Query all ItemListeners registered with this component.

Returns:
An array of Item Listeners.

getItemMap

public java.util.Hashtable getItemMap()
Query the Hashtable of items.

Returns:
Hashtable of items.

isPopupVisible

public boolean isPopupVisible()
Returns true if the pop-up might be currently visible.

Returns:
false if the pop-up definitely is not visible.

setScaleFactor

public void setScaleFactor(double value)
Set the scale factor used to reduce image sizes.

Parameters:
value - scale factor to use.

getScaleFactor

public double getScaleFactor()
Query the scale factor used to reduce image sizes.

Returns:
scale factor to use.

getSelectedIndex

public int getSelectedIndex()
Query the index of the currently selected item.

Returns:
the currently selected index.

setSelectedItem

public void setSelectedItem(java.lang.Object item)
Set the specified item to be selected.

Parameters:
item - the item to select.

getSelectedObjects

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

Specified by:
getSelectedObjects in interface java.awt.ItemSelectable
Returns:
an array of selected objects.

addItem

public void addItem(java.lang.Object item)
Add an Item to the selection list.

Parameters:
item - to add.

addItemListener

public void addItemListener(java.awt.event.ItemListener listener)
Add an ItemListener.

Specified by:
addItemListener in interface java.awt.ItemSelectable
Parameters:
listener - to add.

hidePopup

public void hidePopup()
Hide the popup selection menu.


processItemEvent

public void processItemEvent(java.awt.event.ItemEvent event)
Called to process an ItemEvent.

Parameters:
event - to process.

removeItem

public void removeItem(java.lang.Object item)
Remove an item from the selection list.

Parameters:
item - to remove.

removeItemListener

public void removeItemListener(java.awt.event.ItemListener listener)
Remove an ItemListener.

Specified by:
removeItemListener in interface java.awt.ItemSelectable
Parameters:
listener - to remove.

replaceItemEvent

public java.awt.event.ItemEvent replaceItemEvent(java.awt.event.ItemEvent event)
Called to replace the selection string with the selection Object in an ItemEvent.

Parameters:
event - the ItemEvent generated by the ItemSelectable
Returns:
the replacement ItemEvent

showChoice

public void showChoice()

showEditor

public void showEditor()

showPopup

public void showPopup()
Show the item selection menu. This is done by sending a mouse event to the Choice box.


processEvent

protected void processEvent(java.awt.AWTEvent event)
Called to process an event.

Overrides:
processEvent in class java.awt.Container
Parameters:
event - to process.