Quaqua 8.0 2011-10-02

ch.randelshofer.quaqua
Class QuaquaComboBoxUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.ComboBoxUI
          extended by javax.swing.plaf.basic.BasicComboBoxUI
              extended by ch.randelshofer.quaqua.QuaquaComboBoxUI
All Implemented Interfaces:
VisuallyLayoutable

public class QuaquaComboBoxUI
extends javax.swing.plaf.basic.BasicComboBoxUI
implements VisuallyLayoutable

Quaqua UI for JComboBox.

Version:
$Id: QuaquaComboBoxUI.java 445 2011-10-02 11:15:50Z wrandelshofer $
Author:
Werner Randelshofer

Nested Class Summary
 class QuaquaComboBoxUI.GlowFocusHandler
          This listener hides the popup when the focus is lost.
 
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
static java.lang.String IS_TABLE_CELL_EDITOR
           
 
Fields inherited from class javax.swing.plaf.basic.BasicComboBoxUI
arrowButton, cachedMinimumSize, comboBox, currentValuePane, editor, focusListener, hasFocus, isMinimumSizeDirty, itemListener, keyListener, listBox, listDataListener, popup, popupKeyListener, popupMouseListener, popupMouseMotionListener, propertyChangeListener
 
Fields inherited from interface ch.randelshofer.quaqua.VisuallyLayoutable
CLIP_BOUNDS, COMPONENT_BOUNDS, TEXT_BOUNDS
 
Constructor Summary
QuaquaComboBoxUI()
           
 
Method Summary
protected  javax.swing.JButton createArrowButton()
           
protected  javax.swing.ComboBoxEditor createEditor()
           
protected  java.awt.event.FocusListener createFocusListener()
          Creates a FocusListener which will be added to the combo box.
protected  java.awt.event.KeyListener createKeyListener()
           
protected  java.awt.LayoutManager createLayoutManager()
           
protected  javax.swing.event.ListDataListener createListDataListener()
          Creates a list data listener which will be added to the ComboBoxModel.
protected  javax.swing.plaf.basic.ComboPopup createPopup()
           
 java.beans.PropertyChangeListener createPropertyChangeListener()
           
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
          Preferred spacing between combo boxes and other components.
protected  void editablePropertyChanged(java.beans.PropertyChangeEvent e)
          Deprecated. As of Java 2 platform v1.4.
protected  javax.swing.Icon getArrowIcon()
           
protected  int getArrowWidth()
           
 int getBaseline(javax.swing.JComponent c, int width, int height)
          Returns the baseline for the specified component, or -1 if the baseline can not be determined.
protected  java.awt.Dimension getDisplaySize()
          Returns the calculated size of the display area.
 java.awt.event.KeyListener getKeyListener()
           
protected  java.awt.Insets getMargin()
           
 java.awt.Dimension getMaximumSize(javax.swing.JComponent c)
           
 java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
          Note: Changes in this method also require changes in method rectangelForCurrentValue.
 java.awt.Rectangle getVisualBounds(javax.swing.JComponent c, int layoutType, int width, int height)
          Returns the visual bounds for the specified component, or null if the visual bounds can not be determined.
protected  void installDefaults()
           
protected  void installListeners()
          Create and install the listeners for the combo box and its model.
 void installUI(javax.swing.JComponent c)
           
protected  boolean isNavigationKey(int keyCode)
          Returns whether or not the supplied keyCode maps to a key that is used for navigation.
protected  boolean isSmall()
           
 void layoutComboBox(java.awt.Container parent, ch.randelshofer.quaqua.QuaquaComboBoxUI.QuaquaComboBoxUIHandler manager)
           
 void paint(java.awt.Graphics g, javax.swing.JComponent c)
           
 void paintCurrentValue(java.awt.Graphics g, java.awt.Rectangle bounds, boolean hasFocus)
           
 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.
protected  java.awt.Rectangle rectangleForCurrentValue(int width, int height)
          Returns the area that is reserved for drawing the currently selected item.
protected  void removeListeners()
          Deprecated. As of Java 2 platform v1.4.
protected  void uninstallListeners()
          Remove the installed listeners from the combo box and its model.
 
Methods inherited from class javax.swing.plaf.basic.BasicComboBoxUI
addEditor, configureArrowButton, configureEditor, createItemListener, createRenderer, getAccessibleChild, getAccessibleChildrenCount, getBaselineResizeBehavior, getDefaultSize, getInsets, getPreferredSize, installComponents, installKeyboardActions, isFocusTraversable, isPopupVisible, removeEditor, selectNextPossibleValue, selectPreviousPossibleValue, setPopupVisible, toggleOpenClose, unconfigureArrowButton, unconfigureEditor, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallUI
 
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

IS_TABLE_CELL_EDITOR

public static final java.lang.String IS_TABLE_CELL_EDITOR
See Also:
Constant Field Values
Constructor Detail

QuaquaComboBoxUI

public QuaquaComboBoxUI()
Method Detail

createUI

public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
Preferred spacing between combo boxes and other components. / private final static Insets regularSpacing = new Insets(12,12,12,12); private final static Insets smallSpacing = new Insets(10,10,10,10); private final static Insets miniSpacing = new Insets(8,8,8,8);


installUI

public void installUI(javax.swing.JComponent c)
Overrides:
installUI in class javax.swing.plaf.basic.BasicComboBoxUI

installDefaults

protected void installDefaults()
Overrides:
installDefaults in class javax.swing.plaf.basic.BasicComboBoxUI

installListeners

protected void installListeners()
Create and install the listeners for the combo box and its model. This method is called when the UI is installed.

Overrides:
installListeners in class javax.swing.plaf.basic.BasicComboBoxUI

uninstallListeners

protected void uninstallListeners()
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

Overrides:
uninstallListeners in class javax.swing.plaf.basic.BasicComboBoxUI

getKeyListener

public java.awt.event.KeyListener getKeyListener()

createEditor

protected javax.swing.ComboBoxEditor createEditor()
Overrides:
createEditor in class javax.swing.plaf.basic.BasicComboBoxUI

createPopup

protected javax.swing.plaf.basic.ComboPopup createPopup()
Overrides:
createPopup in class javax.swing.plaf.basic.BasicComboBoxUI

createArrowButton

protected javax.swing.JButton createArrowButton()
Overrides:
createArrowButton in class javax.swing.plaf.basic.BasicComboBoxUI

createKeyListener

protected java.awt.event.KeyListener createKeyListener()
Overrides:
createKeyListener in class javax.swing.plaf.basic.BasicComboBoxUI

createFocusListener

protected java.awt.event.FocusListener createFocusListener()
Creates 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.

Overrides:
createFocusListener in class javax.swing.plaf.basic.BasicComboBoxUI
Returns:
an instance of a FocusListener or null

createListDataListener

protected javax.swing.event.ListDataListener createListDataListener()
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.

Overrides:
createListDataListener in class javax.swing.plaf.basic.BasicComboBoxUI
Returns:
an instance of a ListDataListener or null

createPropertyChangeListener

public java.beans.PropertyChangeListener createPropertyChangeListener()
Overrides:
createPropertyChangeListener in class javax.swing.plaf.basic.BasicComboBoxUI

paint

public void paint(java.awt.Graphics g,
                  javax.swing.JComponent c)
Overrides:
paint in class javax.swing.plaf.basic.BasicComboBoxUI

paintCurrentValue

public void paintCurrentValue(java.awt.Graphics g,
                              java.awt.Rectangle bounds,
                              boolean hasFocus)
Overrides:
paintCurrentValue in class javax.swing.plaf.basic.BasicComboBoxUI

paintCurrentValueBackground

public void paintCurrentValueBackground(java.awt.Graphics g,
                                        java.awt.Rectangle bounds,
                                        boolean hasFocus)
Paints the background of the currently selected item.

Overrides:
paintCurrentValueBackground in class javax.swing.plaf.basic.BasicComboBoxUI

isNavigationKey

protected boolean isNavigationKey(int keyCode)
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.

Overrides:
isNavigationKey in class javax.swing.plaf.basic.BasicComboBoxUI

editablePropertyChanged

protected void editablePropertyChanged(java.beans.PropertyChangeEvent e)
Deprecated. As of Java 2 platform v1.4.

As of Java 2 platform v1.4 this method is no longer used. Do not call or override. All the functionality of this method is in the QuaquaComboBoxPropertyChangeListener.


createLayoutManager

protected java.awt.LayoutManager createLayoutManager()
Overrides:
createLayoutManager in class javax.swing.plaf.basic.BasicComboBoxUI

layoutComboBox

public void layoutComboBox(java.awt.Container parent,
                           ch.randelshofer.quaqua.QuaquaComboBoxUI.QuaquaComboBoxUIHandler manager)

getArrowIcon

protected javax.swing.Icon getArrowIcon()

getArrowWidth

protected int getArrowWidth()

removeListeners

protected void removeListeners()
Deprecated. As of Java 2 platform v1.4.

As of Java 2 platform v1.4 this method is no longer used.


isSmall

protected boolean isSmall()

rectangleForCurrentValue

protected java.awt.Rectangle rectangleForCurrentValue()
Returns the area that is reserved for drawing the currently selected item. Note: Changes in this method also require changes in method getMinimumSize.

Overrides:
rectangleForCurrentValue in class javax.swing.plaf.basic.BasicComboBoxUI

rectangleForCurrentValue

protected java.awt.Rectangle rectangleForCurrentValue(int width,
                                                      int height)
Returns the area that is reserved for drawing the currently selected item. Note: Changes in this method also require changes in method getMinimumSize.


getMargin

protected java.awt.Insets getMargin()

getDisplaySize

protected java.awt.Dimension getDisplaySize()
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.

Overrides:
getDisplaySize in class javax.swing.plaf.basic.BasicComboBoxUI
Returns:
the size of the display area calculated from the combo box items
See Also:
JComboBox.setPrototypeDisplayValue(java.lang.Object)

getMinimumSize

public java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
Note: Changes in this method also require changes in method rectangelForCurrentValue.

Overrides:
getMinimumSize in class javax.swing.plaf.basic.BasicComboBoxUI

getMaximumSize

public java.awt.Dimension getMaximumSize(javax.swing.JComponent c)
Overrides:
getMaximumSize in class javax.swing.plaf.basic.BasicComboBoxUI

getBaseline

public int getBaseline(javax.swing.JComponent c,
                       int width,
                       int height)
Description copied from interface: VisuallyLayoutable
Returns the baseline for the specified component, or -1 if the baseline can not be determined. The baseline is measured from the top of the component.

Specified by:
getBaseline in interface VisuallyLayoutable
Overrides:
getBaseline in class javax.swing.plaf.basic.BasicComboBoxUI
Parameters:
c - JComponent to calculate baseline for
width - Width of the component to determine baseline for.
height - Height of the component to determine baseline for.
Returns:
baseline for the specified component

getVisualBounds

public java.awt.Rectangle getVisualBounds(javax.swing.JComponent c,
                                          int layoutType,
                                          int width,
                                          int height)
Description copied from interface: VisuallyLayoutable
Returns the visual bounds for the specified component, or null if the visual bounds can not be determined.

Specified by:
getVisualBounds in interface VisuallyLayoutable
Parameters:
c - JComponent to calculate visual margin for
layoutType - The type of the visual margin.
width - Width of the component
height - Height of the component
Returns:
The visual bounds in component coordinates.

Copyright 2003-2007 (c) Werner Randelshofer.
All rights reserved.