com.zfqjava.swing
Class AComboBox

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.zfqjava.swing.AComboBox
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class AComboBox
extends javax.swing.JComponent
implements javax.accessibility.Accessible

AComboBox provides a another combo box.

See Also:
Serialized Form

Inner Class Summary
protected  class AComboBox.AccessibleAComboBox
          This class implements accessibility support for the AComboBox class.
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
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
AComboBox()
          Constructs a combobox.
 
Method Summary
 void addPopupMenuListener(javax.swing.event.PopupMenuListener l)
          Adds a PopupMenu listener which will listen to notification messages from the popup portion of the combo box.
protected  javax.swing.JPopupMenu createPopupMenu()
          Creates the JPopupMenu for the popup component.
protected  void firePopupMenuCanceled()
          Notifies PopupMenuListeners that the popup portion of the combo box has been canceled.
protected  void firePopupMenuWillBecomeInvisible()
          Notifies PopupMenuListeners that the popup portion of the combo box has become invisible.
protected  void firePopupMenuWillBecomeVisible()
          Notifies PopupMenuListeners that the popup portion of the combo box will become visible.
 javax.accessibility.AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this AComboBox.
 javax.swing.ComboBoxEditor getEditor()
          Returns the editor used to paint and edit the selected item in the JComboBox field.
 java.awt.Component getPopupComponent()
          Returns the popup component added into JPopupMenu.
 javax.swing.Icon getPopupIcon()
          Returns the popup icon used for the drop down button icon.
 javax.swing.JPopupMenu getPopupMenu()
          Returns the popup menu.
 javax.swing.event.PopupMenuListener[] getPopupMenuListeners()
          Returns an array of all the PopupMenuListeners added to this JComboBox with addPopupMenuListener().
protected  java.awt.Point getPopupMenuOrigin()
          Computes the origin for the AComboBox's popup menu.
 javax.swing.Renderer getRenderer()
          Returns the renderer used to display the selected item in the JComboBox field.
 java.lang.Object getValue()
          Returns the value for the AComboBox.
 void hidePopup()
          Causes the combo box to close its popup window.
 boolean isEditable()
          Returns true if the JComboBox is editable.
 boolean isLightWeightPopupEnabled()
          Gets the value of the lightWeightPopupEnabled property.
 boolean isPopupVisible()
          Determines the visibility of the popup.
protected  void paintComponent(java.awt.Graphics g)
           
protected  java.lang.String paramString()
          Returns a string representation of this AComboBox.
 void processKeyEvent(java.awt.event.KeyEvent e)
          Handles KeyEvents, looking for the Tab key.
 void removePopupMenuListener(javax.swing.event.PopupMenuListener l)
          Removes a PopupMenuListener.
 void setEditable(boolean aFlag)
          Determines whether the JComboBox field is editable.
 void setEditor(javax.swing.ComboBoxEditor anEditor)
          Sets the editor used to paint and edit the selected item in the JComboBox field.
 void setLightWeightPopupEnabled(boolean aFlag)
          Sets the lightWeightPopupEnabled property, which provides a hint as to whether or not a lightweight Component should be used to contain the JComboBox, versus a heavyweight Component such as a Panel or a Window.
 void setPopupComponent(java.awt.Component popupComponent)
          Sets the popup component added into JPopupMenu.
 void setPopupIcon(javax.swing.Icon popupIcon)
          Sets the popup icon used for the drop down button icon.
 void setPopupMenu(javax.swing.JPopupMenu popupMenu)
          Sets the popup menu.
 void setPopupVisible(boolean v)
          Sets the visibility of the popup.
 void setRenderer(javax.swing.Renderer aRenderer)
          Sets the renderer that paints the list items and the item selected from the list in the JComboBox field.
 void setValue(java.lang.Object value)
          Sets the value for the AComboBox.
 void showPopup()
          Causes the combo box to display its popup window.
 void updateUI()
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, 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, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, 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, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, 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
 

Constructor Detail

AComboBox

public AComboBox()
Constructs a combobox.
Method Detail

updateUI

public void updateUI()
Overrides:
updateUI in class javax.swing.JComponent

setValue

public void setValue(java.lang.Object value)
Sets the value for the AComboBox.
Parameters:
value - the value for the AComboBox
See Also:
getValue()

getValue

public java.lang.Object getValue()
Returns the value for the AComboBox.
Returns:
the value for the AComboBox
See Also:
setValue(java.lang.Object)

setLightWeightPopupEnabled

public void setLightWeightPopupEnabled(boolean aFlag)
Sets the lightWeightPopupEnabled property, which provides a hint as to whether or not a lightweight Component should be used to contain the JComboBox, versus a heavyweight Component such as a Panel or a Window. The decision of lightweight versus heavyweight is ultimately up to the JComboBox. Lightweight windows are more efficient than heavyweight windows, but lightweight and heavyweight components do not mix well in a GUI. If your application mixes lightweight and heavyweight components, you should disable lightweight popups. The default value for the lightWeightPopupEnabled property is true, unless otherwise specified by the look and feel. Some look and feels always use heavyweight popups, no matter what the value of this property.

See the article Mixing Heavy and Light Components on The Swing Connection This method fires a property changed event.

Parameters:
aFlag - if true, lightweight popups are desired

isLightWeightPopupEnabled

public boolean isLightWeightPopupEnabled()
Gets the value of the lightWeightPopupEnabled property.
Returns:
the value of the lightWeightPopupEnabled property
See Also:
setLightWeightPopupEnabled(boolean)

setEditable

public void setEditable(boolean aFlag)
Determines whether the JComboBox field is editable. An editable JComboBox allows the user to type into the field or selected an item from the list to initialize the field, after which it can be edited. (The editing affects only the field, the list item remains intact.) A non editable JComboBox displays the selected item in the field, but the selection cannot be modified.
Parameters:
aFlag - a boolean value, where true indicates that the field is editable

isEditable

public boolean isEditable()
Returns true if the JComboBox is editable. By default, a combo box is not editable.
Returns:
true if the JComboBox is editable, else false

setRenderer

public void setRenderer(javax.swing.Renderer aRenderer)
Sets the renderer that paints the list items and the item selected from the list in the JComboBox field. The renderer is used if the JComboBox is not editable. If it is editable, the editor is used to render and edit the selected item.

The default renderer displays a string or an icon. Other renderers can handle graphic images and composite items.

To display the selected item, aRenderer.getListCellRendererComponent is called, passing the list object and an index of -1.

Parameters:
aRenderer - the ListCellRenderer that displays the selected item
See Also:
setEditor(javax.swing.ComboBoxEditor)

getRenderer

public javax.swing.Renderer getRenderer()
Returns the renderer used to display the selected item in the JComboBox field.
Returns:
the ListCellRenderer that displays the selected item.

setEditor

public void setEditor(javax.swing.ComboBoxEditor anEditor)
Sets the editor used to paint and edit the selected item in the JComboBox field. The editor is used only if the receiving JComboBox is editable. If not editable, the combo box uses the renderer to paint the selected item.
Parameters:
anEditor - the ComboBoxEditor that displays the selected item
See Also:
setRenderer(javax.swing.Renderer)

getEditor

public javax.swing.ComboBoxEditor getEditor()
Returns the editor used to paint and edit the selected item in the JComboBox field.
Returns:
the ComboBoxEditor that displays the selected item

setPopupIcon

public void setPopupIcon(javax.swing.Icon popupIcon)
Sets the popup icon used for the drop down button icon. The default popup icon is arrow icon.
Parameters:
popupIcon - the popup icon used for the drop down button icon
See Also:
getPopupIcon()

getPopupIcon

public javax.swing.Icon getPopupIcon()
Returns the popup icon used for the drop down button icon. The default popup icon is arrow icon.
Returns:
the popup icon used for the drop down button icon

setPopupComponent

public void setPopupComponent(java.awt.Component popupComponent)
Sets the popup component added into JPopupMenu.
Parameters:
popupComponent - the popup component added into JPopupMenu

getPopupComponent

public java.awt.Component getPopupComponent()
Returns the popup component added into JPopupMenu.
Returns:
the popup component added into JPopupMenu

createPopupMenu

protected javax.swing.JPopupMenu createPopupMenu()
Creates the JPopupMenu for the popup component.
Returns:
the JPopupMenu for the popup component

getPopupMenuOrigin

protected java.awt.Point getPopupMenuOrigin()
Computes the origin for the AComboBox's popup menu.
Returns:
a Point in the coordinate space of the menu which should be used as the origin of the AComboBox's popup menu

setPopupMenu

public void setPopupMenu(javax.swing.JPopupMenu popupMenu)
Sets the popup menu.
Parameters:
popupMenu - the popup menu
See Also:
getPopupMenu()

getPopupMenu

public javax.swing.JPopupMenu getPopupMenu()
Returns the popup menu.
Returns:
the popup menu
See Also:
setPopupMenu(javax.swing.JPopupMenu)

showPopup

public void showPopup()
Causes the combo box to display its popup window.
See Also:
setPopupVisible(boolean)

hidePopup

public void hidePopup()
Causes the combo box to close its popup window.
See Also:
setPopupVisible(boolean)

setPopupVisible

public void setPopupVisible(boolean v)
Sets the visibility of the popup.

isPopupVisible

public boolean isPopupVisible()
Determines the visibility of the popup.
Returns:
true if the popup is visible, otherwise returns false

paintComponent

protected void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

addPopupMenuListener

public void addPopupMenuListener(javax.swing.event.PopupMenuListener l)
Adds a PopupMenu listener which will listen to notification messages from the popup portion of the combo box.

For all standard look and feels shipped with Java 2, the popup list portion of combo box is implemented as a JPopupMenu. A custom look and feel may not implement it this way and will therefore not receive the notification.

Parameters:
l - the PopupMenuListener to add

removePopupMenuListener

public void removePopupMenuListener(javax.swing.event.PopupMenuListener l)
Removes a PopupMenuListener.
Parameters:
l - the PopupMenuListener to remove
See Also:
addPopupMenuListener(javax.swing.event.PopupMenuListener)

getPopupMenuListeners

public javax.swing.event.PopupMenuListener[] getPopupMenuListeners()
Returns an array of all the PopupMenuListeners added to this JComboBox with addPopupMenuListener().
Returns:
all of the PopupMenuListeners added or an empty array if no listeners have been added

firePopupMenuWillBecomeVisible

protected void firePopupMenuWillBecomeVisible()
Notifies PopupMenuListeners that the popup portion of the combo box will become visible.

This method is public but should not be called by anything other than the UI delegate.

See Also:
addPopupMenuListener(javax.swing.event.PopupMenuListener)

firePopupMenuWillBecomeInvisible

protected void firePopupMenuWillBecomeInvisible()
Notifies PopupMenuListeners that the popup portion of the combo box has become invisible.

This method is public but should not be called by anything other than the UI delegate.

See Also:
addPopupMenuListener(javax.swing.event.PopupMenuListener)

firePopupMenuCanceled

protected void firePopupMenuCanceled()
Notifies PopupMenuListeners that the popup portion of the combo box has been canceled.

This method is public but should not be called by anything other than the UI delegate.

See Also:
addPopupMenuListener(javax.swing.event.PopupMenuListener)

processKeyEvent

public void processKeyEvent(java.awt.event.KeyEvent e)
Handles KeyEvents, looking for the Tab key. If the Tab key is found, the popup window is closed.
Overrides:
processKeyEvent in class javax.swing.JComponent
Parameters:
e - the KeyEvent containing the keyboard key that was pressed

paramString

protected java.lang.String paramString()
Returns a string representation of this AComboBox. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
Overrides:
paramString in class javax.swing.JComponent
Returns:
a string representation of this AComboBox.

getAccessibleContext

public javax.accessibility.AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this AComboBox. For AComboBoxs, the AccessibleContext takes the form of an AccessibleAComboBox. A new AccessibleAComboBox instance is created if necessary.
Specified by:
getAccessibleContext in interface javax.accessibility.Accessible
Overrides:
getAccessibleContext in class javax.swing.JComponent
Returns:
an AccessibleAComboBox that serves as the AccessibleContext of this AComboBox


Copyright © 2001-2003 Extreme Component, Inc. All rights reserved.