| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public class BasicComboBoxUI extends ComboBoxUI
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 Class Summary | |
---|---|
class |
This layout manager handles the 'standard' layout of combo boxes. |
class |
This listener hides the popup when the focus is lost. |
class |
This listener watches for changes to the selection in the combo box. |
class |
This listener checks to see if the key event isn't a navigation key. |
class |
This listener watches for changes in the ComboBoxModel . |
class |
This listener watches for bound properties that have changed in the combo box. |
Field Summary | |
---|---|
protected JButton |
arrowButton
|
protected Dimension |
cachedMinimumSize
|
protected JComboBox |
comboBox
|
protected CellRendererPane |
currentValuePane
|
protected Component |
editor
|
protected FocusListener |
focusListener
This protected field is implementation specific. |
protected boolean |
hasFocus
This protected field is implementation specific. |
protected boolean |
isMinimumSizeDirty
|
protected ItemListener |
itemListener
This protected field is implementation specific. |
protected KeyListener |
keyListener
This protected field is implementation specific. |
protected JList |
listBox
|
protected ListDataListener |
listDataListener
This protected field is implementation specific. |
protected ComboPopup |
popup
|
protected KeyListener |
popupKeyListener
|
protected MouseListener |
popupMouseListener
|
protected MouseMotionListener |
popupMouseMotionListener
|
protected PropertyChangeListener |
propertyChangeListener
This protected field is implementation specific. |
Constructor Summary | |
---|---|
|
Method Summary | |
---|---|
void |
This public method is implementation specific and should be private. |
void |
This public method is implementation specific and should be private. |
protected void |
This protected method is implementation specific and should be private. |
protected JButton |
Creates an button which will be used as the control to show or hide the popup portion of the combo box. |
protected ComboBoxEditor |
Creates the default editor that will be used in editable combo boxes. |
protected FocusListener |
Creates a FocusListener which will be added to the combo box.
|
protected ItemListener |
Creates an ItemListener which will be added to the
combo box.
|
protected KeyListener |
Creates a KeyListener which will be added to the
combo box.
|
protected LayoutManager |
Creates a layout manager for managing the components which make up the combo box. |
protected ListDataListener |
Creates a list data listener which will be added to the ComboBoxModel .
|
protected ComboPopup |
Creates the popup portion of the combo box. |
protected PropertyChangeListener |
Creates a PropertyChangeListener which will be added to
the combo box.
|
protected ListCellRenderer |
Creates the default renderer that will be used in a non-editiable combo box. |
static ComponentUI |
|
Accessible |
getAccessibleChild(JComponent c, int i) Returns the i th Accessible child of the object.
|
int |
Returns the number of accessible children in the object. |
int |
getBaseline(JComponent c, int width, int height) Returns the baseline. |
Component.BaselineResizeBehavior |
Returns an enum indicating how the baseline of the component changes as the size changes. |
protected Dimension |
Return the default size of an empty display area of the combo box using the current renderer and font. |
protected Dimension |
Returns the calculated size of the display area. |
protected Insets |
Gets the insets from the JComboBox. |
Dimension |
Returns the specified component's maximum size appropriate for the look and feel. |
Dimension |
The minumum size is the size of the display area plus insets plus the button. |
Dimension |
Returns the specified component's preferred size appropriate for the look and feel. |
protected void |
Creates and initializes the components which make up the aggregate combo box. |
protected void |
Installs the default colors, default font, default renderer, and default editor into the JComboBox. |
protected void |
Adds keyboard actions to the JComboBox. |
protected void |
Create and install the listeners for the combo box and its model. |
void |
Configures the specified component appropriate for the look and feel. |
boolean |
Determines if the JComboBox is focus traversable. |
protected boolean |
isNavigationKey(int keyCode) Returns whether or not the supplied keyCode maps to a key that is used for navigation. |
boolean |
Tells if the popup is visible or not. |
void |
paint(Graphics g, JComponent c) Paints the specified component appropriate for the look and feel. |
void |
paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) Paints the currently selected item. |
void |
paintCurrentValueBackground(Graphics g, Rectangle bounds, boolean hasFocus) Paints the background of the currently selected item. |
protected Rectangle |
Returns the area that is reserved for drawing the currently selected item. |
void |
This public method is implementation specific and should be private. |
protected void |
Selects the next item in the list. |
protected void |
Selects the previous item in the list. |
void |
setPopupVisible(JComboBox c, boolean v) Hides the popup. |
protected void |
Hides the popup if it is showing and shows the popup if it is hidden. |
void |
This public method is implementation specific and should be private. |
protected void |
This protected method is implementation specific and should be private. |
protected void |
The aggregate components which compise the combo box are unregistered and uninitialized. |
protected void |
Uninstalls the default colors, default font, default renderer, and default editor into the JComboBox. |
protected void |
Removes the focus InputMap and ActionMap. |
protected void |
Remove the installed listeners from the combo box and its model. |
void |
Reverses configuration which was done on the specified component during installUI .
|
Methods inherited from class javax.swing.plaf.ComboBoxUI |
---|
isFocusTraversable, isPopupVisible, setPopupVisible |
Methods inherited from class javax.swing.plaf.ComponentUI |
---|
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, installUI, paint, uninstallUI, update |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected JButton arrowButton
protected Dimension cachedMinimumSize
protected JComboBox comboBox
protected CellRendererPane currentValuePane
protected Component editor
protected FocusListener focusListener
protected boolean hasFocus
protected boolean isMinimumSizeDirty
protected ItemListener itemListener
protected KeyListener keyListener
protected JList listBox
protected ListDataListener listDataListener
protected ComboPopup popup
protected KeyListener popupKeyListener
protected MouseListener popupMouseListener
protected MouseMotionListener popupMouseMotionListener
protected PropertyChangeListener propertyChangeListener
Constructor Detail |
---|
public BasicComboBoxUI()
Method Detail |
---|
public void addEditor()
ComboBoxEditor
public void configureArrowButton()
protected void configureEditor()
protected JButton createArrowButton()
protected ComboBoxEditor createEditor()
setEditor
.
ComboBoxEditor
used for the combo boxprotected FocusListener createFocusListener()
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 nullprotected ItemListener createItemListener()
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 nullprotected KeyListener createKeyListener()
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 nullprotected LayoutManager createLayoutManager()
protected ListDataListener createListDataListener()
ComboBoxModel
. If this method returns null then
it will not be added to the combo box model.
ListDataListener
or nullprotected ComboPopup createPopup()
ComboPopup
protected PropertyChangeListener createPropertyChangeListener()
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 nullprotected ListCellRenderer createRenderer()
setRenderer
.
ListCellRender
used for the combo boxpublic static ComponentUI createUI(JComponent c)
c
public Accessible getAccessibleChild(JComponent c, int i)
getAccessibleChild
in class ComponentUI
c
i
public int getAccessibleChildrenCount(JComponent c)
getAccessibleChildrenCount
in class ComponentUI
c
public int getBaseline(JComponent c, int width, int height)
getBaseline
in class ComponentUI
c
width
height
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
getBaselineResizeBehavior
in class ComponentUI
c
protected Dimension getDefaultSize()
protected Dimension getDisplaySize()
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.
protected Insets getInsets()
public Dimension getMaximumSize(JComponent c)
getMaximumSize
in class ComponentUI
c
public Dimension getMinimumSize(JComponent c)
getMinimumSize
in class ComponentUI
c
public Dimension getPreferredSize(JComponent c)
getPreferredSize
in class ComponentUI
c
protected void installComponents()
protected void installDefaults()
protected void installKeyboardActions()
protected void installListeners()
public void installUI(JComponent c)
installUI
in class ComponentUI
c
public boolean isFocusTraversable(JComboBox c)
isFocusTraversable
in class ComboBoxUI
c
protected boolean isNavigationKey(int keyCode)
keyCode
public boolean isPopupVisible(JComboBox c)
isPopupVisible
in class ComboBoxUI
c
public void paint(Graphics g, JComponent c)
paint
in class ComponentUI
g
c
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus)
g
bounds
hasFocus
public void paintCurrentValueBackground(Graphics g, Rectangle bounds, boolean hasFocus)
g
bounds
hasFocus
protected Rectangle rectangleForCurrentValue()
public void removeEditor()
protected void selectNextPossibleValue()
protected void selectPreviousPossibleValue()
public void setPopupVisible(JComboBox c, boolean v)
setPopupVisible
in class ComboBoxUI
c
v
protected void toggleOpenClose()
public void unconfigureArrowButton()
protected void unconfigureEditor()
protected void uninstallComponents()
protected void uninstallDefaults()
protected void uninstallKeyboardActions()
protected void uninstallListeners()
installListeners
public void uninstallUI(JComponent c)
uninstallUI
in class ComponentUI
c
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |