Home » openjdk-7 » javax » swing » plaf » basic » [javadoc | source]
javax.swing.plaf.basic
public class: BasicComboBoxUI [javadoc | source]
java.lang.Object
   javax.swing.plaf.ComponentUI
      javax.swing.plaf.ComboBoxUI
         javax.swing.plaf.basic.BasicComboBoxUI

Direct Known Subclasses:
    MetalComboBoxUI, SynthComboBoxUI

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:
public class  BasicComboBoxUI.KeyHandler  This listener checks to see if the key event isn't a navigation key. If it finds a key event that wasn't a navigation key it dispatches it to JComboBox.selectWithKeyChar() so that it can do type-ahead. This public inner class should be treated as protected. Instantiate it only within subclasses of BasicComboBoxUI
public class  BasicComboBoxUI.FocusHandler  This listener hides the popup when the focus is lost. It also repaints when focus is gained or lost. This public inner class should be treated as protected. Instantiate it only within subclasses of BasicComboBoxUI
public class  BasicComboBoxUI.ListDataHandler  This listener watches for changes in the ComboBoxModel.

This public inner class should be treated as protected. Instantiate it only within subclasses of BasicComboBoxUI

public class  BasicComboBoxUI.ItemHandler  This listener watches for changes to the selection in the combo box.

This public inner class should be treated as protected. Instantiate it only within subclasses of BasicComboBoxUI

public class  BasicComboBoxUI.PropertyChangeHandler  This listener watches for bound properties that have changed in the combo box.

Subclasses which wish to listen to combo box property changes should call the superclass methods to ensure that the combo box ui correctly handles property changes.

This public inner class should be treated as protected. Instantiate it only within subclasses of BasicComboBoxUI

public class  BasicComboBoxUI.ComboBoxLayoutManager  This layout manager handles the 'standard' layout of combo boxes. It puts the arrow button to the right and the editor to the left. If there is no editor it still keeps the arrow button to the right. This public inner class should be treated as protected. Instantiate it only within subclasses of BasicComboBoxUI
class  BasicComboBoxUI.DefaultKeySelectionManager   
Field Summary
protected  JComboBox comboBox     
protected  boolean hasFocus    This protected field is implementation specific. Do not access directly or override. 
protected  JList listBox     
protected  CellRendererPane currentValuePane     
protected  ComboPopup popup     
protected  Component editor     
protected  JButton arrowButton     
protected  KeyListener keyListener    This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead. 
protected  FocusListener focusListener    This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead. 
protected  PropertyChangeListener propertyChangeListener    This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead. 
protected  ItemListener itemListener    This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead. 
protected  MouseListener popupMouseListener     
protected  MouseMotionListener popupMouseMotionListener     
protected  KeyListener popupKeyListener     
protected  ListDataListener listDataListener    This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead. 
 KeySelectionManager keySelectionManager    The default key selection manager 
protected  boolean isMinimumSizeDirty     
protected  Dimension cachedMinimumSize     
static final  StringBuffer HIDE_POPUP_KEY     
protected  boolean squareButton    Indicates whether or not the combo box button should be square. If square, then the width and height are equal, and are both set to the height of the combo minus appropriate insets.
    since: 1.7 -
 
protected  Insets padding    If specified, these insets act as padding around the cell renderer when laying out and painting the "selected" item in the combo box. These insets add to those specified by the cell renderer.
    since: 1.7 -
 
Method from javax.swing.plaf.basic.BasicComboBoxUI Summary:
addEditor,   configureArrowButton,   configureEditor,   createArrowButton,   createEditor,   createFocusListener,   createItemListener,   createKeyListener,   createLayoutManager,   createListDataListener,   createPopup,   createPropertyChangeListener,   createRenderer,   createUI,   getAccessibleChild,   getAccessibleChildrenCount,   getBaseline,   getBaselineResizeBehavior,   getDefaultSize,   getDisplaySize,   getInputMap,   getInsets,   getMaximumSize,   getMinimumSize,   getPreferredSize,   getSizeForComponent,   installComponents,   installDefaults,   installKeyboardActions,   installListeners,   installUI,   isFocusTraversable,   isNavigationKey,   isPopupVisible,   isTableCellEditor,   loadActionMap,   paint,   paintCurrentValue,   paintCurrentValueBackground,   rectangleForCurrentValue,   removeEditor,   repaintCurrentValue,   selectNextPossibleValue,   selectPreviousPossibleValue,   setPopupVisible,   toggleOpenClose,   unconfigureArrowButton,   unconfigureEditor,   uninstallComponents,   uninstallDefaults,   uninstallKeyboardActions,   uninstallListeners,   uninstallUI
Methods from javax.swing.plaf.ComboBoxUI:
isFocusTraversable,   isPopupVisible,   setPopupVisible
Methods from javax.swing.plaf.ComponentUI:
contains,   createUI,   getAccessibleChild,   getAccessibleChildrenCount,   getBaseline,   getBaselineResizeBehavior,   getMaximumSize,   getMinimumSize,   getPreferredSize,   installUI,   paint,   uninstallUI,   update
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.plaf.basic.BasicComboBoxUI Detail:
 public  void addEditor() 
    This public method is implementation specific and should be private. do not call or override. To implement a specific editor create a custom ComboBoxEditor
 public  void configureArrowButton() 
    This public method is implementation specific and should be private. Do not call or override.
 protected  void configureEditor() 
    This protected method is implementation specific and should be private. do not call or override.
 protected JButton createArrowButton() 
    Creates a button which will be used as the control to show or hide the popup portion of the combo box.
 protected ComboBoxEditor createEditor() 
    Creates the default editor that will be used in editable combo boxes. A default editor will be used only if an editor has not been explicitly set with setEditor.
 protected 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.
 protected ItemListener createItemListener() 
    Creates an 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.

 protected KeyListener createKeyListener() 
    Creates a KeyListener which will be added to the combo box. If this method returns null then it will not be added to the combo box.
 protected LayoutManager createLayoutManager() 
    Creates a layout manager for managing the components which make up the combo box.
 protected 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.
 protected ComboPopup createPopup() 
    Creates the popup portion of the combo box.
 protected PropertyChangeListener createPropertyChangeListener() 
    Creates a PropertyChangeListener which will be added to the combo box. If this method returns null then it will not be added to the combo box.
 protected 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 with setRenderer.
 public static ComponentUI createUI(JComponent c) 
 public Accessible getAccessibleChild(JComponent c,
    int i) 
 public int getAccessibleChildrenCount(JComponent c) 
 public int getBaseline(JComponent c,
    int width,
    int height) 
    Returns the baseline.
 public BaselineResizeBehavior getBaselineResizeBehavior(JComponent c) 
    Returns an enum indicating how the baseline of the component changes as the size changes.
 protected Dimension getDefaultSize() 
    Return the default size of an empty display area of the combo box using the current renderer and font.
 protected 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.

 InputMap getInputMap(int condition) 
 protected Insets getInsets() 
    Gets the insets from the JComboBox.
 public Dimension getMaximumSize(JComponent c) 
 public Dimension getMinimumSize(JComponent c) 
    The minumum size is the size of the display area plus insets plus the button.
 public Dimension getPreferredSize(JComponent c) 
 protected Dimension getSizeForComponent(Component comp) 
    Returns the size a component would have if used as a cell renderer.
 protected  void installComponents() 
    Creates and initializes the components which make up the aggregate combo box. This method is called as part of the UI installation process.
 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. Actions on enter and esc are already supplied. Add more actions as you need them.
 protected  void installListeners() 
    Creates and installs listeners for the combo box and its model. This method is called when the UI is installed.
 public  void installUI(JComponent c) 
 public boolean isFocusTraversable(JComboBox c) 
    Determines if the JComboBox is focus traversable. If the JComboBox is editable this returns false, otherwise it returns true.
 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.
 public boolean isPopupVisible(JComboBox c) 
    Tells if the popup is visible or not.
 boolean isTableCellEditor() 
 static  void loadActionMap(LazyActionMap map) 
    Populates ComboBox's actions.
 public  void paint(Graphics g,
    JComponent c) 
 public  void paintCurrentValue(Graphics g,
    Rectangle bounds,
    boolean hasFocus) 
    Paints the currently selected item.
 public  void paintCurrentValueBackground(Graphics g,
    Rectangle bounds,
    boolean hasFocus) 
    Paints the background of the currently selected item.
 protected Rectangle rectangleForCurrentValue() 
    Returns the area that is reserved for drawing the currently selected item.
 public  void removeEditor() 
    This public method is implementation specific and should be private. do not call or override.
  void repaintCurrentValue() 
    Repaint the currently selected item.
 protected  void selectNextPossibleValue() 
    Selects the next item in the list. It won't change the selection if the currently selected item is already the last item.
 protected  void selectPreviousPossibleValue() 
    Selects the previous item in the list. It won't change the selection if the currently selected item is already the first item.
 public  void setPopupVisible(JComboBox c,
    boolean v) 
    Hides the popup.
 protected  void toggleOpenClose() 
    Hides the popup if it is showing and shows the popup if it is hidden.
 public  void unconfigureArrowButton() 
    This public method is implementation specific and should be private. Do not call or override.
 protected  void unconfigureEditor() 
    This protected method is implementation specific and should be private. Do not call or override.
 protected  void uninstallComponents() 
    The aggregate components which compise the combo box are unregistered and uninitialized. This method is called as part of the UI uninstallation process.
 protected  void uninstallDefaults() 
    Uninstalls the default colors, default font, default renderer, and default editor from the combo box.
 protected  void uninstallKeyboardActions() 
    Removes the focus InputMap and ActionMap.
 protected  void uninstallListeners() 
    Removes 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
 public  void uninstallUI(JComponent c)