Package com.jgoodies.looks.plastic
Class PlasticComboBoxUI
- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.ComboBoxUI
-
- javax.swing.plaf.basic.BasicComboBoxUI
-
- javax.swing.plaf.metal.MetalComboBoxUI
-
- com.jgoodies.looks.plastic.PlasticComboBoxUI
-
public class PlasticComboBoxUI extends javax.swing.plaf.metal.MetalComboBoxUIThe JGoodies Plastic Look and Feel implementation ofComboBoxUI. 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 Plastic L&fs implemented via a client property key.
- Version:
- $Revision: 1.19 $
- See Also:
Options.COMBO_POPUP_PROTOTYPE_DISPLAY_VALUE_KEY
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classPlasticComboBoxUI.PlasticComboBoxLayoutManagerThis layout manager handles the 'standard' layout of combo boxes.private static classPlasticComboBoxUI.PlasticComboPopupDiffers from the BasicComboPopup in that it uses the standard popmenu border and honors an optional popup prototype display value.private classPlasticComboBoxUI.PlasticPropertyChangeListenerOverriden to use PlasticComboBoxButton instead of a MetalComboBoxButton.private classPlasticComboBoxUI.TableCellEditorPropertyChangeHandlerListens to changes in the table cell editor client property and updates the default editor - if any - to use the correct insets for this case.-
Nested classes/interfaces inherited from class javax.swing.plaf.metal.MetalComboBoxUI
javax.swing.plaf.metal.MetalComboBoxUI.MetalComboBoxLayoutManager, javax.swing.plaf.metal.MetalComboBoxUI.MetalComboPopup, javax.swing.plaf.metal.MetalComboBoxUI.MetalPropertyChangeListener
-
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicComboBoxUI
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
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.StringCELL_EDITOR_KEYprivate static javax.swing.JTextFieldPHANTOMUsed to determine the minimum height of a text field, which in turn is used to answer the combobox's minimum height.private static java.lang.ClassphantomLafClassDifferent Plastic L&fs may need different phantom UIs.private java.beans.PropertyChangeListenerpropertyChangeListenerprivate booleantableCellEditor-
Fields inherited from class javax.swing.plaf.basic.BasicComboBoxUI
arrowButton, cachedMinimumSize, comboBox, currentValuePane, editor, focusListener, hasFocus, isMinimumSizeDirty, itemListener, keyListener, listBox, listDataListener, padding, popup, popupKeyListener, popupMouseListener, popupMouseMotionListener, squareButton
-
-
Constructor Summary
Constructors Constructor Description PlasticComboBoxUI()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.swing.JButtoncreateArrowButton()Creates and answers the arrow button that is to be used in the combo box.protected javax.swing.ComboBoxEditorcreateEditor()Creates the editor that is to be used in editable combo boxes.protected java.awt.LayoutManagercreateLayoutManager()Creates a layout manager for managing the components which make up the combo box.protected javax.swing.plaf.basic.ComboPopupcreatePopup()java.beans.PropertyChangeListenercreatePropertyChangeListener()protected javax.swing.ListCellRenderercreateRenderer()Creates the default renderer that will be used in a non-editiable combo box.static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent b)private static voidensurePhantomHasPlasticUI()Ensures that the phantom text field has a Plastic text field UI.(package private) static intgetEditableButtonWidth()Computes and returns the width of the arrow button in editable state.java.awt.DimensiongetMinimumSize(javax.swing.JComponent c)The minumum size is the size of the display area plus insets plus the button.java.awt.DimensiongetPreferredSize(javax.swing.JComponent c)Delegates to #getMinimumSize(Component).protected voidinstallListeners()voidinstallUI(javax.swing.JComponent c)private booleanisTableCellEditor()Checks and answers if this UI's combo has a client property that indicates that the combo is used as a table cell editor.protected booleanisToolBarComboBox(javax.swing.JComponent c)Checks and answers if this combo is in a tool bar.protected java.awt.RectanglerectangleForCurrentValue()Returns the area that is reserved for drawing the currently selected item.protected voiduninstallListeners()voidupdate(java.awt.Graphics g, javax.swing.JComponent c)-
Methods inherited from class javax.swing.plaf.metal.MetalComboBoxUI
configureEditor, editablePropertyChanged, getBaseline, layoutComboBox, paint, paintCurrentValue, paintCurrentValueBackground, removeListeners, unconfigureEditor
-
Methods inherited from class javax.swing.plaf.basic.BasicComboBoxUI
addEditor, configureArrowButton, createFocusListener, createItemListener, createKeyListener, createListDataListener, getAccessibleChild, getAccessibleChildrenCount, getBaselineResizeBehavior, getDefaultSize, getDisplaySize, getInsets, getMaximumSize, getSizeForComponent, installComponents, installDefaults, installKeyboardActions, isFocusTraversable, isNavigationKey, isPopupVisible, removeEditor, selectNextPossibleValue, selectPreviousPossibleValue, setPopupVisible, toggleOpenClose, unconfigureArrowButton, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallUI
-
-
-
-
Field Detail
-
CELL_EDITOR_KEY
static final java.lang.String CELL_EDITOR_KEY
- See Also:
- Constant Field Values
-
PHANTOM
private static final javax.swing.JTextField PHANTOM
Used to determine the minimum height of a text field, which in turn is used to answer the combobox's minimum height.
-
phantomLafClass
private static java.lang.Class phantomLafClass
Different Plastic L&fs may need different phantom UIs. Therefore we store the LookAndFeel class and update the phantom UI whenever the Look&Feel changes.
-
tableCellEditor
private boolean tableCellEditor
-
propertyChangeListener
private java.beans.PropertyChangeListener propertyChangeListener
-
-
Method Detail
-
createUI
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent b)
-
ensurePhantomHasPlasticUI
private static void ensurePhantomHasPlasticUI()
Ensures that the phantom text field has a Plastic text field UI.
-
installUI
public void installUI(javax.swing.JComponent c)
- Overrides:
installUIin classjavax.swing.plaf.basic.BasicComboBoxUI
-
installListeners
protected void installListeners()
- Overrides:
installListenersin classjavax.swing.plaf.basic.BasicComboBoxUI
-
uninstallListeners
protected void uninstallListeners()
- Overrides:
uninstallListenersin classjavax.swing.plaf.basic.BasicComboBoxUI
-
createArrowButton
protected javax.swing.JButton createArrowButton()
Creates and answers the arrow button that is to be used in the combo box.Overridden to use a button that can have a pseudo 3D effect.
- Overrides:
createArrowButtonin classjavax.swing.plaf.metal.MetalComboBoxUI
-
createEditor
protected javax.swing.ComboBoxEditor createEditor()
Creates the editor that is to be used in editable combo boxes. This method only gets called if a custom editor has not already been installed in the JComboBox.- Overrides:
createEditorin classjavax.swing.plaf.metal.MetalComboBoxUI
-
createLayoutManager
protected java.awt.LayoutManager createLayoutManager()
Creates a layout manager for managing the components which make up the combo box.Overriden to use a layout that has a fixed width arrow button.
- Overrides:
createLayoutManagerin classjavax.swing.plaf.metal.MetalComboBoxUI- Returns:
- an instance of a layout manager
-
createPopup
protected javax.swing.plaf.basic.ComboPopup createPopup()
- Overrides:
createPopupin classjavax.swing.plaf.metal.MetalComboBoxUI
-
createRenderer
protected javax.swing.ListCellRenderer createRenderer()
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 withsetRenderer.This method differs from the superclass implementation in that it uses an empty border with wider left and right margins of 2 pixels instead of 1.
- Overrides:
createRendererin classjavax.swing.plaf.basic.BasicComboBoxUI- Returns:
- a
ListCellRenderused for the combo box - See Also:
JComboBox.setRenderer(javax.swing.ListCellRenderer<? super E>)
-
getMinimumSize
public java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
The minumum size is the size of the display area plus insets plus the button.- Overrides:
getMinimumSizein classjavax.swing.plaf.metal.MetalComboBoxUI
-
getPreferredSize
public java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
Delegates to #getMinimumSize(Component). Overridden to return the same result in JDK 1.5 as in JDK 1.4.- Overrides:
getPreferredSizein classjavax.swing.plaf.basic.BasicComboBoxUI
-
rectangleForCurrentValue
protected java.awt.Rectangle rectangleForCurrentValue()
Returns the area that is reserved for drawing the currently selected item.- Overrides:
rectangleForCurrentValuein classjavax.swing.plaf.basic.BasicComboBoxUI
-
update
public void update(java.awt.Graphics g, javax.swing.JComponent c)- Overrides:
updatein classjavax.swing.plaf.ComponentUI
-
isToolBarComboBox
protected boolean isToolBarComboBox(javax.swing.JComponent c)
Checks and answers if this combo is in a tool bar.- Parameters:
c- the component to check- Returns:
- true if in tool bar, false otherwise
-
getEditableButtonWidth
static int getEditableButtonWidth()
Computes and returns the width of the arrow button in editable state. The perceived width shall be equal to the width of a scroll bar. Therefore we subtract a pixel that is perceived as part of the arrow button but that is painted by the editor's border.- Returns:
- the width of the arrow button in editable state
-
isTableCellEditor
private boolean isTableCellEditor()
Checks and answers if this UI's combo has a client property that indicates that the combo is used as a table cell editor.- Returns:
trueif the table cell editor client property is set toBoolean.TRUE,falseotherwise
-
createPropertyChangeListener
public java.beans.PropertyChangeListener createPropertyChangeListener()
- Overrides:
createPropertyChangeListenerin classjavax.swing.plaf.metal.MetalComboBoxUI
-
-