|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.plaf.ComponentUI
net.sf.sbcc.componentcombo.plaf.ComponentComboBoxUI
net.sf.sbcc.componentcombo.plaf.basic.BasicComponentComboBoxUI
public class BasicComponentComboBoxUI
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 | |
---|---|
private static class |
BasicComponentComboBoxUI.Actions
|
class |
BasicComponentComboBoxUI.ComboBoxLayoutManager
This layout manager handles the 'standard' layout of combo boxes. |
(package private) class |
BasicComponentComboBoxUI.DefaultKeySelectionManager
|
class |
BasicComponentComboBoxUI.FocusHandler
This listener hides the popup when the focus is lost. |
private class |
BasicComponentComboBoxUI.Handler
|
class |
BasicComponentComboBoxUI.ItemHandler
This listener watches for changes to the selection in the combo box. |
class |
BasicComponentComboBoxUI.KeyHandler
This listener checks to see if the key event isn't a navigation key. |
class |
BasicComponentComboBoxUI.PropertyChangeHandler
This listener watches for bound properties that have changed in the combo box. |
class |
BasicComponentComboBoxUI.SimpleDataHandler
This listener watches for changes in the ComboBoxModel . |
Field Summary | |
---|---|
protected javax.swing.JButton |
arrowButton
|
private java.awt.Dimension |
cachedDisplaySize
|
protected java.awt.Dimension |
cachedMinimumSize
|
private static java.lang.Object |
COMBO_UI_LIST_CELL_RENDERER_KEY
|
protected JAbstractComponentComboBox |
comboBox
|
protected javax.swing.CellRendererPane |
currentValuePane
|
protected SimpleDataListener |
dataListener
This protected field is implementation specific. |
protected java.awt.Component |
editor
|
protected java.awt.event.FocusListener |
focusListener
This protected field is implementation specific. |
private BasicComponentComboBoxUI.Handler |
handler
Implements all the Listeners needed by this class, all existing listeners redirect to it. |
protected boolean |
hasFocus
This protected field is implementation specific. |
(package private) static java.lang.StringBuffer |
HIDE_POPUP_KEY
|
private boolean |
isDisplaySizeDirty
|
protected boolean |
isMinimumSizeDirty
|
protected java.awt.event.ItemListener |
itemListener
This protected field is implementation specific. |
protected java.awt.event.KeyListener |
keyListener
This protected field is implementation specific. |
(package private) JAbstractComponentComboBox.KeySelectionManager |
keySelectionManager
The default key selection manager |
private long |
lastTime
This is tricky, this variables is needed for DefaultKeySelectionManager to take into account time factor. |
protected ComponentComboPopup |
popup
|
protected javax.swing.JComponent |
popupComponent
|
protected java.awt.event.KeyListener |
popupKeyListener
|
protected java.awt.event.MouseListener |
popupMouseListener
|
protected java.awt.event.MouseMotionListener |
popupMouseMotionListener
|
protected java.beans.PropertyChangeListener |
propertyChangeListener
This protected field is implementation specific. |
private long |
time
|
private long |
timeFactor
The time factor to treate the series of typed alphanumeric key as prefix for first letter navigation. |
Constructor Summary | |
---|---|
BasicComponentComboBoxUI()
|
Method Summary | |
---|---|
private static java.lang.Object |
_getUIOfType(javax.swing.plaf.ComponentUI ui,
java.lang.Class klass)
Returns the ui that is of type klass , or null if
one can not be found. |
void |
addEditor()
This public method is implementation specific and should be private. |
void |
configureArrowButton()
This public method is implementation specific and should be private. |
protected void |
configureEditor()
This protected method is implementation specific and should be private. |
protected javax.swing.JButton |
createArrowButton()
Creates an button which will be used as the control to show or hide the popup portion of the combo box. |
protected SimpleDataListener |
createDataListener()
Creates a list data listener which will be added to the ComboBoxModel . |
protected javax.swing.ComboBoxEditor |
createEditor()
Creates the default editor that will be used in editable combo boxes. |
protected java.awt.event.FocusListener |
createFocusListener()
Creates a FocusListener which will be added to the combo box. |
protected java.awt.event.ItemListener |
createItemListener()
Creates an ItemListener which will be added to the
combo box. |
protected java.awt.event.KeyListener |
createKeyListener()
Creates a KeyListener which will be added to the
combo box. |
protected java.awt.LayoutManager |
createLayoutManager()
Creates a layout manager for managing the components which make up the combo box. |
protected ComponentComboPopup |
createPopup()
Creates the popup portion of the combo box. |
protected java.beans.PropertyChangeListener |
createPropertyChangeListener()
Creates a PropertyChangeListener which will be added to
the combo box. |
protected javax.swing.ListCellRenderer |
createRenderer()
Creates the default renderer that will be used in a non-editiable combo box. |
static javax.swing.plaf.ComponentUI |
createUI(javax.swing.JComponent c)
|
javax.accessibility.Accessible |
getAccessibleChild(javax.swing.JComponent c,
int i)
|
int |
getAccessibleChildrenCount(javax.swing.JComponent c)
|
private static javax.swing.ListCellRenderer |
getDefaultListCellRenderer()
|
protected java.awt.Dimension |
getDisplaySize()
Returns the calculated size of the display area. |
private BasicComponentComboBoxUI.Handler |
getHandler()
Returns the shared listener. |
(package private) javax.swing.InputMap |
getInputMap(int condition)
|
protected java.awt.Insets |
getInsets()
Gets the insets from the JComboBox. |
java.awt.Dimension |
getMaximumSize(javax.swing.JComponent c)
|
java.awt.Dimension |
getMinimumSize(javax.swing.JComponent c)
The minumum size is the size of the display area plus insets plus the button. |
java.awt.Dimension |
getPreferredSize(javax.swing.JComponent c)
|
private java.awt.Dimension |
getSizeForComponent(java.awt.Component comp)
This has been refactored out in hopes that it may be investigated and simplified for the next major release. adding/removing the component to the currentValuePane and changing the font may be redundant operations. |
protected void |
installComponents()
Creates and initializes the components which make up the aggregate combo box. |
protected void |
installDefaults()
Installs the default colors, default font, default renderer, and default editor into the JComboBox. |
protected void |
installKeyboardActions()
Adds keyboard actions to the JComboBox. |
protected void |
installListeners()
Create and install the listeners for the combo box and its model. |
void |
installUI(javax.swing.JComponent c)
|
boolean |
isFocusTraversable(JAbstractComponentComboBox c)
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. |
private boolean |
isNavigationKey(int keyCode,
int modifiers)
|
boolean |
isPopupVisible(JAbstractComponentComboBox c)
Tells if the popup is visible or not. |
(package private) static void |
loadActionMap(LazyActionMap map)
Populates ComboBox's actions. |
void |
paint(java.awt.Graphics g,
javax.swing.JComponent c)
|
void |
paintCurrentValue(java.awt.Graphics g,
java.awt.Rectangle bounds,
boolean hasFocus)
Paints the currently selected item. |
void |
paintCurrentValueBackground(java.awt.Graphics g,
java.awt.Rectangle bounds,
boolean hasFocus)
Paints the background of the currently selected item. |
protected java.awt.Rectangle |
rectangleForCurrentValue()
Returns the area that is reserved for drawing the currently selected item. |
void |
removeEditor()
This public method is implementation specific and should be private. |
(package private) void |
repaintCurrentValue()
Repaint the currently selected item. |
void |
setPopupVisible(JAbstractComponentComboBox c,
boolean v)
Hides the popup. |
protected void |
toggleOpenClose()
Hides the popup if it is showing and shows the popup if it is hidden. |
void |
unconfigureArrowButton()
This public method is implementation specific and should be private. |
protected void |
unconfigureEditor()
This protected method is implementation specific and should be private. |
protected void |
uninstallComponents()
The aggregate components which compise the combo box are unregistered and uninitialized. |
protected void |
uninstallDefaults()
Uninstalls the default colors, default font, default renderer, and default editor into the JComboBox. |
protected void |
uninstallKeyboardActions()
Removes the focus InputMap and ActionMap. |
protected void |
uninstallListeners()
Remove the installed listeners from the combo box and its model. |
void |
uninstallUI(javax.swing.JComponent c)
|
private void |
updateToolTipTextForChildren()
|
Methods inherited from class javax.swing.plaf.ComponentUI |
---|
contains, update |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected JAbstractComponentComboBox comboBox
protected boolean hasFocus
protected javax.swing.JComponent popupComponent
protected javax.swing.CellRendererPane currentValuePane
protected ComponentComboPopup popup
protected java.awt.Component editor
protected javax.swing.JButton arrowButton
protected java.awt.event.KeyListener keyListener
createKeyListener()
protected java.awt.event.FocusListener focusListener
createFocusListener()
protected java.beans.PropertyChangeListener propertyChangeListener
createPropertyChangeListener()
protected java.awt.event.ItemListener itemListener
createItemListener()
protected java.awt.event.MouseListener popupMouseListener
protected java.awt.event.MouseMotionListener popupMouseMotionListener
protected java.awt.event.KeyListener popupKeyListener
protected SimpleDataListener dataListener
#createListDataListener
private BasicComponentComboBoxUI.Handler handler
private long timeFactor
private long lastTime
private long time
JAbstractComponentComboBox.KeySelectionManager keySelectionManager
protected boolean isMinimumSizeDirty
protected java.awt.Dimension cachedMinimumSize
private boolean isDisplaySizeDirty
private java.awt.Dimension cachedDisplaySize
private static final java.lang.Object COMBO_UI_LIST_CELL_RENDERER_KEY
static final java.lang.StringBuffer HIDE_POPUP_KEY
Constructor Detail |
---|
public BasicComponentComboBoxUI()
Method Detail |
---|
private static javax.swing.ListCellRenderer getDefaultListCellRenderer()
static void loadActionMap(LazyActionMap map)
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
public void installUI(javax.swing.JComponent c)
installUI
in class javax.swing.plaf.ComponentUI
public void uninstallUI(javax.swing.JComponent c)
uninstallUI
in class javax.swing.plaf.ComponentUI
protected void installDefaults()
protected void installListeners()
protected void uninstallDefaults()
protected void uninstallListeners()
installListeners
protected ComponentComboPopup createPopup()
ComboPopup
ComponentComboPopup
protected java.awt.event.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 java.awt.event.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 SimpleDataListener createDataListener()
ComboBoxModel
. If this method returns null then
it will not be added to the combo box model.
ListDataListener
or nullprotected java.awt.event.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 java.beans.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 java.awt.LayoutManager createLayoutManager()
protected javax.swing.ListCellRenderer createRenderer()
setRenderer
.
ListCellRender
used for the combo boxJComboBox.setRenderer(javax.swing.ListCellRenderer)
protected javax.swing.ComboBoxEditor createEditor()
setEditor
.
ComboBoxEditor
used for the combo boxjavax.swing.JAbstractComponentComboBox#setEditor
private BasicComponentComboBoxUI.Handler getHandler()
private void updateToolTipTextForChildren()
protected void installComponents()
protected void uninstallComponents()
public void addEditor()
ComboBoxEditor
createEditor()
,
JComboBox.setEditor(javax.swing.ComboBoxEditor)
,
ComboBoxEditor
public void removeEditor()
addEditor()
protected void configureEditor()
addEditor()
protected void unconfigureEditor()
addEditor()
public void configureArrowButton()
createArrowButton()
public void unconfigureArrowButton()
createArrowButton()
protected javax.swing.JButton createArrowButton()
public boolean isPopupVisible(JAbstractComponentComboBox c)
isPopupVisible
in class ComponentComboBoxUI
public void setPopupVisible(JAbstractComponentComboBox c, boolean v)
setPopupVisible
in class ComponentComboBoxUI
public boolean isFocusTraversable(JAbstractComponentComboBox c)
isFocusTraversable
in class ComponentComboBoxUI
public void paint(java.awt.Graphics g, javax.swing.JComponent c)
paint
in class javax.swing.plaf.ComponentUI
public java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
getPreferredSize
in class javax.swing.plaf.ComponentUI
public java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
getMinimumSize
in class javax.swing.plaf.ComponentUI
public java.awt.Dimension getMaximumSize(javax.swing.JComponent c)
getMaximumSize
in class javax.swing.plaf.ComponentUI
public int getAccessibleChildrenCount(javax.swing.JComponent c)
getAccessibleChildrenCount
in class javax.swing.plaf.ComponentUI
public javax.accessibility.Accessible getAccessibleChild(javax.swing.JComponent c, int i)
getAccessibleChild
in class javax.swing.plaf.ComponentUI
protected boolean isNavigationKey(int keyCode)
private boolean isNavigationKey(int keyCode, int modifiers)
protected void toggleOpenClose()
protected java.awt.Rectangle rectangleForCurrentValue()
protected java.awt.Insets getInsets()
public void paintCurrentValue(java.awt.Graphics g, java.awt.Rectangle bounds, boolean hasFocus)
public void paintCurrentValueBackground(java.awt.Graphics g, java.awt.Rectangle bounds, boolean hasFocus)
void repaintCurrentValue()
protected java.awt.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.
JComboBox.setPrototypeDisplayValue(java.lang.Object)
private java.awt.Dimension getSizeForComponent(java.awt.Component comp)
protected void installKeyboardActions()
javax.swing.InputMap getInputMap(int condition)
protected void uninstallKeyboardActions()
private static java.lang.Object _getUIOfType(javax.swing.plaf.ComponentUI ui, java.lang.Class klass)
klass
, or null if
one can not be found.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |