JComponentPack 1.5.0

com.zfqjava.swing
Class AComboBox

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.zfqjava.swing.AComboBox
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class AComboBox
extends JComponent
implements Accessible

AComboBox provides a another combo box.

See Also:
Serialized Form

Nested Class Summary
static class AComboBox.AbstractComponentFactory
           
protected  class AComboBox.AccessibleAComboBox
          This class implements accessibility support for the AComboBox class.
 
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
 
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 addActionListener(ActionListener l)
          Adds an ActionListener.
 void addPopupMenuListener(PopupMenuListener l)
          Adds a PopupMenu listener which will listen to notification messages from the popup portion of the combo box.
protected  JPopupMenu createPopupMenu()
          Creates the JPopupMenu for the popup component.
protected  void fireActionPerformed(ActionEvent e)
          Notifies all listeners that have registered interest for notification on this event type.
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.
 AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this AComboBox.
 ActionListener[] getActionListeners()
          Returns an array of all the ActionListeners added to this JComboBox with addActionListener().
 AComboBox.AbstractComponentFactory getComponentFactory()
           
 ComboBoxEditor getEditor()
          Returns the editor used to paint and edit the selected item in the JComboBox field.
 Component getPopupComponent()
          Returns the popup component added into JPopupMenu.
 Icon getPopupIcon()
          Returns the popup icon used for the drop down button icon.
 JPopupMenu getPopupMenu()
          Returns the popup menu.
 PopupMenuListener[] getPopupMenuListeners()
          Returns an array of all the PopupMenuListeners added to this JComboBox with addPopupMenuListener().
protected  Point getPopupMenuOrigin()
          Computes the origin for the AComboBox's popup menu.
 Renderer getRenderer()
          Returns the renderer used to display the selected item in the JComboBox field.
 Object getValue()
          Returns the value for the AComboBox.
 Class getValueClass()
          Returns the value type.
 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 paintBorder(Graphics g)
           
protected  void paintComponent(Graphics g)
           
protected  String paramString()
          Returns a string representation of this AComboBox.
 void processKeyEvent(KeyEvent e)
          Handles KeyEvents, looking for the Tab key.
 void removeActionListener(ActionListener l)
          Removes an ActionListener.
 void removePopupMenuListener(PopupMenuListener l)
          Removes a PopupMenuListener.
 void setComponentFactory(AComboBox.AbstractComponentFactory componentFactory)
           
 void setEditable(boolean aFlag)
          Determines whether the JComboBox field is editable.
 void setEditor(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(Component popupComponent)
          Sets the popup component added into JPopupMenu.
 void setPopupIcon(Icon popupIcon)
          Sets the popup icon used for the drop down button icon.
 void setPopupMenu(JPopupMenu popupMenu)
          Sets the popup menu.
 void setPopupVisible(boolean v)
          Sets the visibility of the popup.
 void setRenderer(Renderer aRenderer)
          Sets the renderer that paints the list items and the item selected from the list in the JComboBox field.
 void setValue(Object value)
          Sets the value for the AComboBox.
 void setValueClass(Class valueClass)
          Sets the value class, the AComboBox will configure the AbstractComponentFactory based the value class.
 void showPopup()
          Causes the combo box to display its popup window.
 void 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, 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, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, 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, 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, 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
 

Constructor Detail

AComboBox

public AComboBox()
Constructs a combobox.

Method Detail

updateUI

public void updateUI()
Overrides:
updateUI in class JComponent

paintBorder

protected void paintBorder(Graphics g)
Overrides:
paintBorder in class JComponent

setValue

public void setValue(Object value)
Sets the value for the AComboBox.

Parameters:
value - the value for the AComboBox
See Also:
getValue()

getValue

public Object getValue()
Returns the value for the AComboBox.

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

getValueClass

public Class getValueClass()
Returns the value type.

Returns:
returns the value type
Since:
JComponentPack 1.3 JDataGrid 2.7

setValueClass

public void setValueClass(Class valueClass)
Sets the value class, the AComboBox will configure the AbstractComponentFactory based the value class.

Parameters:
valueClass - the value type
Since:
JComponentPack 1.3 JDataGrid 2.7

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(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.setValue is called, passing the object.

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

getRenderer

public 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(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 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(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 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(Component popupComponent)
Sets the popup component added into JPopupMenu.

Parameters:
popupComponent - the popup component added into JPopupMenu

getPopupComponent

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

Returns:
the popup component added into JPopupMenu

getComponentFactory

public AComboBox.AbstractComponentFactory getComponentFactory()
Returns:
Since:
JComponentPack 1.1.0

setComponentFactory

public void setComponentFactory(AComboBox.AbstractComponentFactory componentFactory)
Since:
JComponentPack 1.1.0

createPopupMenu

protected JPopupMenu createPopupMenu()
Creates the JPopupMenu for the popup component.

Returns:
the JPopupMenu for the popup component

getPopupMenuOrigin

protected 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(JPopupMenu popupMenu)
Sets the popup menu.

Parameters:
popupMenu - the popup menu
See Also:
getPopupMenu()

getPopupMenu

public 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(Graphics g)
Overrides:
paintComponent in class JComponent

addActionListener

public void addActionListener(ActionListener l)
Adds an ActionListener.

The ActionListener will receive an ActionEvent when a selection has been made. If the combo box is editable, then an ActionEvent will be fired when editing has stopped.

Parameters:
l - the ActionListener that is to be notified
Since:
JComponentPack 1.3 JDataGrid 2.7
See Also:
#setSelectedItem

removeActionListener

public void removeActionListener(ActionListener l)
Removes an ActionListener.

Parameters:
l - the ActionListener to remove
Since:
JComponentPack 1.3 JDataGrid 2.7

getActionListeners

public ActionListener[] getActionListeners()
Returns an array of all the ActionListeners added to this JComboBox with addActionListener().

Returns:
all of the ActionListeners added or an empty array if no listeners have been added
Since:
JComponentPack 1.3 JDataGrid 2.7

fireActionPerformed

protected void fireActionPerformed(ActionEvent e)
Notifies all listeners that have registered interest for notification on this event type.

Parameters:
e - the action event to fire
Since:
JComponentPack 1.3 JDataGrid 2.7
See Also:
EventListenerList

addPopupMenuListener

public void addPopupMenuListener(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(PopupMenuListener l)
Removes a PopupMenuListener.

Parameters:
l - the PopupMenuListener to remove
See Also:
addPopupMenuListener(javax.swing.event.PopupMenuListener)

getPopupMenuListeners

public 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(KeyEvent e)
Handles KeyEvents, looking for the Tab key. If the Tab key is found, the popup window is closed.

Overrides:
processKeyEvent in class JComponent
Parameters:
e - the KeyEvent containing the keyboard key that was pressed

paramString

protected 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 JComponent
Returns:
a string representation of this AComboBox.

getAccessibleContext

public 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 Accessible
Overrides:
getAccessibleContext in class JComponent
Returns:
an AccessibleAComboBox that serves as the AccessibleContext of this AComboBox

JComponentPack 1.5.0

Send your Feedback
JComponentPack 1.5.0
Copyright © 2001-2007 Extreme Component, Inc. All rights reserved.