Class SmartComboBox<T>

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JComboBox
org.pentaho.reporting.libraries.designtime.swing.SmartComboBox<T>
All Implemented Interfaces:
ActionListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, ListDataListener
Direct Known Subclasses:
ColorComboBox, FontFamilyComboBox

public class SmartComboBox<T> extends JComboBox
A combobox that does not check whether a selected item is part of the model when the box is not editable.
Author:
Thomas Morgner.
See Also:
  • Constructor Details

    • SmartComboBox

      public SmartComboBox(ComboBoxModel aModel)
      Creates a JComboBox that takes it's items from an existing ComboBoxModel. Since the ComboBoxModel is provided, a combo box created using this constructor does not create a default combo box model and may impact how the insert, remove and add methods behave.
      Parameters:
      aModel - the ComboBoxModel that provides the displayed list of items
      See Also:
    • SmartComboBox

      public SmartComboBox(T[] items)
      Creates a JComboBox that contains the elements in the specified array. By default the first item in the array (and therefore the data model) becomes selected.
      Parameters:
      items - an array of objects to insert into the combo box
      See Also:
    • SmartComboBox

      public SmartComboBox()
      Creates a JComboBox with a default data model. The default data model is an empty list of objects. Use addItem to add items. By default the first item in the data model becomes selected.
      See Also:
  • Method Details

    • setSelectedItem

      public void setSelectedItem(Object anObject)
      Sets the selected item in the combo box display area to the object in the argument. If anObject is in the list, the display area shows anObject selected.

      If anObject is not in the list and the combo box is uneditable, it will not change the current selection. For editable combo boxes, the selection will change to anObject.

      If this constitutes a change in the selected item, ItemListeners added to the combo box will be notified with one or two ItemEvents. If there is a current selected item, an ItemEvent will be fired and the state change will be ItemEvent.DESELECTED. If anObject is in the list and is not currently selected then an ItemEvent will be fired and the state change will be ItemEvent.SELECTED.

      ActionListeners added to the combo box will be notified with an ActionEvent when this method is called.

      Overrides:
      setSelectedItem in class JComboBox
      Parameters:
      anObject - the list object to select; use null to clear the selection
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      This method is public as an implementation side effect. do not call or override.
      Specified by:
      actionPerformed in interface ActionListener
      Overrides:
      actionPerformed in class JComboBox
    • contentsChanged

      public void contentsChanged(ListDataEvent e)
      This method is public as an implementation side effect. do not call or override.
      Specified by:
      contentsChanged in interface ListDataListener
      Overrides:
      contentsChanged in class JComboBox