public class WindowsComboBoxUI
extends com.sun.java.swing.plaf.windows.WindowsComboBoxUI
ComboBoxUI
.
Corrects the editor insets for editable combo boxes
as well as the render insets for non-editable combos. And it has
the same height as text fields - unless you change the renderer.Also, this class offers to use the combo's popup prototype display value to compute the popup menu width. This is an optional feature of the JGoodies Windows L&f implemented via a client property key.
Options.COMBO_POPUP_PROTOTYPE_DISPLAY_VALUE_KEY
com.sun.java.swing.plaf.windows.WindowsComboBoxUI.WindowsComboBoxEditor
javax.swing.plaf.basic.BasicComboBoxUI.ComboBoxLayoutManager, javax.swing.plaf.basic.BasicComboBoxUI.FocusHandler, javax.swing.plaf.basic.BasicComboBoxUI.ItemHandler, javax.swing.plaf.basic.BasicComboBoxUI.KeyHandler, javax.swing.plaf.basic.BasicComboBoxUI.ListDataHandler, javax.swing.plaf.basic.BasicComboBoxUI.PropertyChangeHandler
arrowButton, cachedMinimumSize, comboBox, currentValuePane, editor, focusListener, hasFocus, isMinimumSizeDirty, itemListener, keyListener, listBox, listDataListener, padding, popup, popupKeyListener, popupMouseListener, popupMouseMotionListener, squareButton
Constructor and Description |
---|
WindowsComboBoxUI() |
Modifier and Type | Method and Description |
---|---|
protected void |
configureEditor() |
protected javax.swing.JButton |
createArrowButton()
Creates the arrow button that is to be used in the combo box.
|
protected javax.swing.ComboBoxEditor |
createEditor()
Creates the editor that is to be used in editable combo boxes.
|
protected java.awt.LayoutManager |
createLayoutManager()
Creates a layout manager for managing the components which
make up the combo box.
|
protected javax.swing.plaf.basic.ComboPopup |
createPopup()
Creates a ComboPopup that honors the optional combo popup display value
that is used to compute the popup menu width.
|
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 b) |
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)
Delegates to #getMinimumSize(Component).
|
protected void |
installListeners() |
void |
installUI(javax.swing.JComponent c) |
protected boolean |
isRendererBorderRemovable(javax.swing.JComponent rendererComponent)
Checks and answer whether the border of the given renderer component
can be removed temporarily, so the combo's selection background will
be consistent with the default renderer and native appearance.
|
void |
paintCurrentValue(java.awt.Graphics g,
java.awt.Rectangle bounds,
boolean hasFocus)
Paints the currently selected item.
|
protected java.awt.Rectangle |
rectangleForCurrentValue()
Returns the area that is reserved for drawing the currently selected item.
|
protected void |
uninstallListeners() |
installKeyboardActions, paint, paintCurrentValueBackground, unconfigureEditor, uninstallUI
addEditor, configureArrowButton, createFocusListener, createItemListener, createKeyListener, createListDataListener, createPropertyChangeListener, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getDefaultSize, getDisplaySize, getInsets, getMaximumSize, getSizeForComponent, installComponents, installDefaults, isFocusTraversable, isNavigationKey, isPopupVisible, removeEditor, selectNextPossibleValue, selectPreviousPossibleValue, setPopupVisible, toggleOpenClose, unconfigureArrowButton, uninstallComponents, uninstallDefaults, uninstallKeyboardActions
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent b)
public void installUI(javax.swing.JComponent c)
installUI
in class com.sun.java.swing.plaf.windows.WindowsComboBoxUI
protected void installListeners()
installListeners
in class com.sun.java.swing.plaf.windows.WindowsComboBoxUI
protected void uninstallListeners()
uninstallListeners
in class com.sun.java.swing.plaf.windows.WindowsComboBoxUI
protected javax.swing.JButton createArrowButton()
Overridden to paint black triangles.
createArrowButton
in class com.sun.java.swing.plaf.windows.WindowsComboBoxUI
protected javax.swing.ComboBoxEditor createEditor()
createEditor
in class com.sun.java.swing.plaf.windows.WindowsComboBoxUI
protected java.awt.LayoutManager createLayoutManager()
Overriden to use a layout that has a fixed width arrow button.
createLayoutManager
in class com.sun.java.swing.plaf.windows.WindowsComboBoxUI
protected void configureEditor()
configureEditor
in class com.sun.java.swing.plaf.windows.WindowsComboBoxUI
protected javax.swing.plaf.basic.ComboPopup createPopup()
createPopup
in class com.sun.java.swing.plaf.windows.WindowsComboBoxUI
protected javax.swing.ListCellRenderer createRenderer()
setRenderer
.This method differs from the superclass implementation in that it uses an empty border with the default left and right text insets, the same as used by a combo box editor.
createRenderer
in class com.sun.java.swing.plaf.windows.WindowsComboBoxUI
ListCellRender
used for the combo boxJComboBox.setRenderer(javax.swing.ListCellRenderer<? super E>)
public java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
getMinimumSize
in class com.sun.java.swing.plaf.windows.WindowsComboBoxUI
public java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
getPreferredSize
in class javax.swing.plaf.basic.BasicComboBoxUI
public void paintCurrentValue(java.awt.Graphics g, java.awt.Rectangle bounds, boolean hasFocus)
paintCurrentValue
in class com.sun.java.swing.plaf.windows.WindowsComboBoxUI
protected boolean isRendererBorderRemovable(javax.swing.JComponent rendererComponent)
#paintCurrentValue
.
It is safe to remove an EmptyBorder if the component doesn't override
#update
, #paint
and #paintBorder
.
Since we know the default renderer, we can remove its border.
Custom renderers may set a hint to make their border removable.
To do so, set the client property "isBorderRemovable"
to Boolean.TRUE
. If this client property is set,
its value will be returned. If it is not set, true
is returned
if and only if the component's border is an EmptyBorder.
rendererComponent
- the renderer component to checkpaintCurrentValue(Graphics, Rectangle, boolean)
protected java.awt.Rectangle rectangleForCurrentValue()
rectangleForCurrentValue
in class javax.swing.plaf.basic.BasicComboBoxUI
Copyright © 2001-2009 JGoodies Karsten Lentzsch. All Rights Reserved.