| JavaTM 2 Platform Std. Ed. v1.6.0
javax.swing
Class JComboBox
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JComboBox
- All Implemented Interfaces:
- ActionListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, ListDataListener
public class JComboBox - extends JComponent
- implements ItemSelectable, ListDataListener, ActionListener, Accessible
A component that combines a button or editable field and a drop-down list.
The user can select a value from the drop-down list, which appears at the
user's request. If you make the combo box editable, then the combo box
includes an editable field into which the user can type a value.
Warning: Swing is not thread safe. For more
information see Swing's Threading
Policy.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans package.
Please see XMLEncoder.
See How to Use Combo Boxes
in The Java Tutorial
for further information.
- See Also:
ComboBoxModel,
DefaultComboBoxModel
|
Constructor Summary |
JComboBox()
Creates a JComboBox with a default data model. |
JComboBox(ComboBoxModel aModel)
Creates a JComboBox that takes its items from an
existing ComboBoxModel. |
JComboBox(Object[] items)
Creates a JComboBox that contains the elements
in the specified array. |
JComboBox(Vector<?> items)
Creates a JComboBox that contains the elements
in the specified Vector. |
| 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, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, 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 |
dataModel
protected ComboBoxModel dataModel
- This protected field is implementation specific. Do not access directly
or override. Use the accessor methods instead.
- See Also:
getModel(),
setModel(javax.swing.ComboBoxModel)
renderer
protected ListCellRenderer renderer
- This protected field is implementation specific. Do not access directly
or override. Use the accessor methods instead.
- See Also:
getRenderer(),
setRenderer(javax.swing.ListCellRenderer)
editor
protected ComboBoxEditor editor
- This protected field is implementation specific. Do not access directly
or override. Use the accessor methods instead.
- See Also:
getEditor(),
setEditor(javax.swing.ComboBoxEditor)
maximumRowCount
protected int maximumRowCount
- This protected field is implementation specific. Do not access directly
or override. Use the accessor methods instead.
- See Also:
getMaximumRowCount(),
setMaximumRowCount(int)
isEditable
protected boolean isEditable
- This protected field is implementation specific. Do not access directly
or override. Use the accessor methods instead.
- See Also:
isEditable,
setEditable(boolean)
keySelectionManager
protected JComboBox.KeySelectionManager keySelectionManager
- This protected field is implementation specific. Do not access directly
or override. Use the accessor methods instead.
- See Also:
setKeySelectionManager(javax.swing.JComboBox.KeySelectionManager),
getKeySelectionManager()
actionCommand
protected String actionCommand
- This protected field is implementation specific. Do not access directly
or override. Use the accessor methods instead.
- See Also:
setActionCommand(java.lang.String),
getActionCommand()
lightWeightPopupEnabled
protected boolean lightWeightPopupEnabled
- This protected field is implementation specific. Do not access directly
or override. Use the accessor methods instead.
- See Also:
setLightWeightPopupEnabled(boolean),
isLightWeightPopupEnabled()
selectedItemReminder
protected Object selectedItemReminder
- This protected field is implementation specific. Do not access directly
or override.
JComboBox
public JComboBox(ComboBoxModel aModel)
- Creates a
JComboBox that takes its items from an
existing ComboBoxModel. Since the
ComboBoxModel is provided, a combo box created using
this constructor does not create a default combo box model and
may impact how the insert, remove and add methods behave.
- Parameters:
aModel - the ComboBoxModel that provides the
displayed list of items- See Also:
DefaultComboBoxModel
JComboBox
public JComboBox(Object[] items)
- Creates a
JComboBox that contains the elements
in the specified array. By default the first item in the array
(and therefore the data model) becomes selected.
- Parameters:
items - an array of objects to insert into the combo box- See Also:
DefaultComboBoxModel
JComboBox
public JComboBox(Vector<?> items)
- Creates a
JComboBox that contains the elements
in the specified Vector. By default the first item in the vector
(and therefore the data model) becomes selected.
- Parameters:
items - an array of vectors to insert into the combo box- See Also:
DefaultComboBoxModel
JComboBox
public JComboBox()
- Creates a
JComboBox with a default data model.
The default data model is an empty list of objects.
Use addItem to add items. By default the first item
in the data model becomes selected.
- See Also:
DefaultComboBoxModel
installAncestorListener
protected void installAncestorListener()
setUI
public void setUI(ComboBoxUI ui)
- Sets the L&F object that renders this component.
- Parameters:
ui - the ComboBoxUI L&F object- See Also:
UIDefaults.getUI(javax.swing.JComponent)
updateUI
public void updateUI()
- Resets the UI property to a value from the current look and feel.
- Overrides:
updateUI in class JComponent
- See Also:
JComponent.updateUI()
getUIClassID
public String getUIClassID()
- Returns the name of the L&F class that renders this component.
- Overrides:
getUIClassID in class JComponent
- Returns:
- the string "ComboBoxUI"
- See Also:
JComponent.getUIClassID(),
UIDefaults.getUI(javax.swing.JComponent)
getUI
public ComboBoxUI getUI()
- Returns the L&F object that renders this component.
- Returns:
- the ComboBoxUI object that renders this component
setModel
public void setModel(ComboBoxModel aModel)
- Sets the data model that the
JComboBox uses to obtain
the list of items.
- Parameters:
aModel - the ComboBoxModel that provides the
displayed list of items
|