java.lang.Object | |||
↳ | javax.swing.plaf.ComponentUI | ||
↳ | javax.swing.plaf.ComboBoxUI | ||
↳ | javax.swing.plaf.basic.BasicComboBoxUI |
![]() |
Basic UI implementation for JComboBox.
The combo box is a compound component which means that it is an agregate of many simpler components. This class creates and manages the listeners on the combo box and the combo box model. These listeners update the user interface in response to changes in the properties and state of the combo box.
All event handling is handled by listener classes created with the
createxxxListener()
methods and internal classes.
You can change the behavior of this class by overriding the
createxxxListener()
methods and supplying your own
event listeners or subclassing from the ones supplied in this class.
For adding specific actions,
overide installKeyboardActions
to add actions in response to
KeyStroke bindings. See the article Keyboard Bindings in Swing
at The Swing Connection.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
BasicComboBoxUI.ComboBoxLayoutManager | This layout manager handles the 'standard' layout of combo boxes. | ||||||||||
BasicComboBoxUI.FocusHandler | This listener hides the popup when the focus is lost. | ||||||||||
BasicComboBoxUI.ItemHandler | This listener watches for changes to the selection in the combo box. | ||||||||||
BasicComboBoxUI.KeyHandler | This listener checks to see if the key event isn't a navigation key. | ||||||||||
BasicComboBoxUI.ListDataHandler | This listener watches for changes in the
ComboBoxModel . |
||||||||||
BasicComboBoxUI.PropertyChangeHandler | This listener watches for bound properties that have changed in the combo box. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
arrowButton | |||||||||||
cachedMinimumSize | |||||||||||
comboBox | |||||||||||
currentValuePane | |||||||||||
editor | |||||||||||
focusListener | This protected field is implementation specific. | ||||||||||
hasFocus | This protected field is implementation specific. | ||||||||||
isMinimumSizeDirty | |||||||||||
itemListener | This protected field is implementation specific. | ||||||||||
keyListener | This protected field is implementation specific. | ||||||||||
listBox | |||||||||||
listDataListener | This protected field is implementation specific. | ||||||||||
popup | |||||||||||
popupKeyListener | |||||||||||
popupMouseListener | |||||||||||
popupMouseMotionListener | |||||||||||
propertyChangeListener | This protected field is implementation specific. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This public method is implementation specific and should be private.
| |||||||||||
This public method is implementation specific and should be private.
| |||||||||||
Returns the
i th Accessible child of the object. | |||||||||||
Returns the number of accessible children in the object.
| |||||||||||
Returns the baseline.
| |||||||||||
Returns an enum indicating how the baseline of the component
changes as the size changes.
| |||||||||||
Returns the specified component's maximum size appropriate for
the look and feel.
| |||||||||||
The minumum size is the size of the display area plus insets plus the button.
| |||||||||||
Returns the specified component's preferred size appropriate for
the look and feel.
| |||||||||||
Configures the specified component appropriate for the look and feel.
| |||||||||||
Determines if the JComboBox is focus traversable.
| |||||||||||
Tells if the popup is visible or not.
| |||||||||||
Paints the specified component appropriate for the look and feel.
| |||||||||||
Paints the currently selected item.
| |||||||||||
Paints the background of the currently selected item.
| |||||||||||
This public method is implementation specific and should be private.
| |||||||||||
Hides the popup.
| |||||||||||
This public method is implementation specific and should be private.
| |||||||||||
Reverses configuration which was done on the specified component during
installUI . |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This protected method is implementation specific and should be private.
| |||||||||||
Creates an button which will be used as the control to show or hide
the popup portion of the combo box.
| |||||||||||
Creates the default editor that will be used in editable combo boxes.
| |||||||||||
Creates a
FocusListener which will be added to the combo box. | |||||||||||
Creates an
ItemListener which will be added to the
combo box. | |||||||||||
Creates a
KeyListener which will be added to the
combo box. | |||||||||||
Creates a layout manager for managing the components which make up the
combo box.
| |||||||||||
Creates a list data listener which will be added to the
ComboBoxModel . | |||||||||||
Creates the popup portion of the combo box.
| |||||||||||
Creates a
PropertyChangeListener which will be added to
the combo box. | |||||||||||
Creates the default renderer that will be used in a non-editiable combo
box.
| |||||||||||
Return the default size of an empty display area of the combo box using
the current renderer and font.
| |||||||||||
Returns the calculated size of the display area.
| |||||||||||
Gets the insets from the JComboBox.
| |||||||||||
Creates and initializes the components which make up the
aggregate combo box.
| |||||||||||
Installs the default colors, default font, default renderer, and default
editor into the JComboBox.
| |||||||||||
Adds keyboard actions to the JComboBox.
| |||||||||||
Create and install the listeners for the combo box and its model.
| |||||||||||
Returns whether or not the supplied keyCode maps to a key that is used for
navigation.
| |||||||||||
Returns the area that is reserved for drawing the currently selected item.
| |||||||||||
Selects the next item in the list.
| |||||||||||
Selects the previous item in the list.
| |||||||||||
Hides the popup if it is showing and shows the popup if it is hidden.
| |||||||||||
This protected method is implementation specific and should be private.
| |||||||||||
The aggregate components which compise the combo box are
unregistered and uninitialized.
| |||||||||||
Uninstalls the default colors, default font, default renderer, and default
editor into the JComboBox.
| |||||||||||
Removes the focus InputMap and ActionMap.
| |||||||||||
Remove the installed listeners from the combo box and its model.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead.
This protected field is implementation specific. Do not access directly or override.
This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead.
This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead.
This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead.
This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead.
This public method is implementation specific and should be private.
do not call or override. To implement a specific editor create a
custom ComboBoxEditor
This public method is implementation specific and should be private. Do not call or override.
Returns the i
th Accessible
child of the object.
UIs might need to override this if they present areas on the
screen that can be viewed as components, but actual components
are not used for presenting those areas.
Note: As of v1.3, it is recommended that developers call
Component.AccessibleAWTComponent.getAccessibleChild()
instead of
this method.
i | zero-based index of child |
---|
i
th Accessible
child of the object
Returns the number of accessible children in the object. If all
of the children of this object implement Accessible
,
this
method should return the number of children of this object.
UIs might wish to override this if they present areas on the
screen that can be viewed as components, but actual components
are not used for presenting those areas.
Note: As of v1.3, it is recommended that developers call
Component.AccessibleAWTComponent.getAccessibleChildrenCount()
instead
of this method.
Returns the baseline.
c | JComponent baseline is being requested for |
---|---|
width | the width to get the baseline for |
height | the height to get the baseline for |
Returns an enum indicating how the baseline of the component changes as the size changes.
c | JComponent to return baseline resize behavior for |
---|
NullPointerException |
---|
Returns the specified component's maximum size appropriate for
the look and feel. If null
is returned, the maximum
size will be calculated by the component's layout manager instead
(this is the preferred approach for any component with a specific
layout manager installed). The default implementation of this
method invokes getPreferredSize
and returns that value.
c | the component whose maximum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components |
---|
Dimension
object or null
The minumum size is the size of the display area plus insets plus the button.
c | the component whose minimum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components |
---|
Dimension
object or null
Returns the specified component's preferred size appropriate for
the look and feel. If null
is returned, the preferred
size will be calculated by the component's layout manager instead
(this is the preferred approach for any component with a specific
layout manager installed). The default implementation of this
method returns null
.
c | the component whose preferred size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components |
---|
Configures the specified component appropriate for the look and feel.
This method is invoked when the ComponentUI
instance is being installed
as the UI delegate on the specified component. This method should
completely configure the component for the look and feel,
including the following:
LayoutManager
on the component if necessary.
PropertyChangeListener
on the component in order
to detect and respond to component property changes appropriately.
c | the component where this UI delegate is being installed |
---|
Determines if the JComboBox is focus traversable. If the JComboBox is editable this returns false, otherwise it returns true.
Paints the specified component appropriate for the look and feel.
This method is invoked from the ComponentUI.update
method when
the specified component is being painted. Subclasses should override
this method and use the specified Graphics
object to
render the content of the component.
g | the Graphics context in which to paint |
---|---|
c | the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components |
Paints the currently selected item.
Paints the background of the currently selected item.
This public method is implementation specific and should be private. do not call or override.
This public method is implementation specific and should be private. Do not call or override.
Reverses configuration which was done on the specified component during
installUI
. This method is invoked when this
UIComponent
instance is being removed as the UI delegate
for the specified component. This method should undo the
configuration performed in installUI
, being careful to
leave the JComponent
instance in a clean state (no
extraneous listeners, look-and-feel-specific property objects, etc.).
This should include the following:
c | the component from which this UI delegate is being removed; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components |
---|
This protected method is implementation specific and should be private. do not call or override.
Creates an button which will be used as the control to show or hide the popup portion of the combo box.
Creates the default editor that will be used in editable combo boxes.
A default editor will be used only if an editor has not been
explicitly set with setEditor
.
ComboBoxEditor
used for the combo boxCreates a FocusListener
which will be added to the combo box.
If this method returns null then it will not be added to the combo box.
FocusListener
or null
Creates an ItemListener
which will be added to the
combo box. If this method returns null then it will not
be added to the combo box.
Subclasses may override this method to return instances of their own ItemEvent handlers.
ItemListener
or null
Creates a KeyListener
which will be added to the
combo box. If this method returns null then it will not be added
to the combo box.
KeyListener
or null
Creates a layout manager for managing the components which make up the combo box.
Creates a list data listener which will be added to the
ComboBoxModel
. If this method returns null then
it will not be added to the combo box model.
ListDataListener
or null
Creates a PropertyChangeListener
which will be added to
the combo box. If this method returns null then it will not
be added to the combo box.
PropertyChangeListener
or null
Creates the default renderer that will be used in a non-editiable combo
box. A default renderer will used only if a renderer has not been
explicitly set with setRenderer
.
ListCellRender
used for the combo boxReturn the default size of an empty display area of the combo box using the current renderer and font.
Returns the calculated size of the display area. The display area is the portion of the combo box in which the selected item is displayed. This method will use the prototype display value if it has been set.
For combo boxes with a non trivial number of items, it is recommended to use a prototype display value to significantly speed up the display size calculation.
Creates and initializes the components which make up the aggregate combo box. This method is called as part of the UI installation process.
Installs the default colors, default font, default renderer, and default editor into the JComboBox.
Adds keyboard actions to the JComboBox. Actions on enter and esc are already supplied. Add more actions as you need them.
Create and install the listeners for the combo box and its model. This method is called when the UI is installed.
Returns whether or not the supplied keyCode maps to a key that is used for navigation. This is used for optimizing key input by only passing non- navigation keys to the type-ahead mechanism. Subclasses should override this if they change the navigation keys.
Returns the area that is reserved for drawing the currently selected item.
Selects the next item in the list. It won't change the selection if the currently selected item is already the last item.
Selects the previous item in the list. It won't change the selection if the currently selected item is already the first item.
Hides the popup if it is showing and shows the popup if it is hidden.
This protected method is implementation specific and should be private. Do not call or override.
The aggregate components which compise the combo box are unregistered and uninitialized. This method is called as part of the UI uninstallation process.
Uninstalls the default colors, default font, default renderer, and default editor into the JComboBox.
Removes the focus InputMap and ActionMap.
Remove the installed listeners from the combo box and its model.
The number and types of listeners removed and in this method should be
the same that was added in installListeners