Class BasicYListUI

Direct Known Subclasses:
BasicXListUI, SynthYListUI

public class BasicYListUI extends YListUI
  • Field Details

    • handler

      protected BasicYListUI.Handler handler
    • DROP_LINE_THICKNESS

      protected static final int DROP_LINE_THICKNESS
      See Also:
    • BASELINE_COMPONENT_KEY

      protected static final StringBuilder BASELINE_COMPONENT_KEY
    • CHANGE_LEAD

      protected static final int CHANGE_LEAD
      Used by IncrementLeadSelectionAction. Indicates the action should change the lead, and not select it.
      See Also:
    • CHANGE_SELECTION

      protected static final int CHANGE_SELECTION
      Used by IncrementLeadSelectionAction. Indicates the action should change the selection and lead.
      See Also:
    • EXTEND_SELECTION

      protected static final int EXTEND_SELECTION
      Used by IncrementLeadSelectionAction. Indicates the action should extend the selection from the anchor to the next index.
      See Also:
    • defaultTransferHandler

      protected static final TransferHandler defaultTransferHandler
  • Constructor Details

    • BasicYListUI

      public BasicYListUI(JComponent c)
  • Method Details

    • createUI

      public static ComponentUI createUI(JComponent c)
    • loadActionMap

      public static void loadActionMap(LazyActionMap map)
    • paintCell

      protected void paintCell(Graphics g, int row, Rectangle rowBounds, ListCellRenderer<Object> cellRenderer, ListModel<Object> dataModel, ListSelectionModel selModel, int leadIndex)
      Paint one List cell: compute the relevant state, get the "rubber stamp" cell renderer component, and then use the CellRendererPane to paint it. Subclasses may want to override this method rather than paint().
      Parameters:
      g - an instance of Graphics
      row - a row
      rowBounds - a bounding rectangle to render to
      cellRenderer - a list of ListCellRenderer
      dataModel - a list model
      selModel - a selection model
      leadIndex - a lead index
      See Also:
    • paint

      public void paint(Graphics g, JComponent c)

      copied from javax.swing.plaf.basic.BasicListUI to call paintImpl

      Overrides:
      paint in class ComponentUI
    • paintImpl

      protected void paintImpl(Graphics g, JComponent c)
    • paintDropLine

      protected void paintDropLine(Graphics g)
    • getDropLineRect

      protected Rectangle getDropLineRect(JList.DropLocation loc)
    • getBaseline

      public int getBaseline(JComponent c, int width, int height)
      Overrides:
      getBaseline in class ComponentUI
    • checkBaselinePrecondition

      protected void checkBaselinePrecondition(JComponent c, int width, int height)
      Fix for Issue #1495: NPE on getBaseline. As per contract, that methods needs to throw Exceptions on illegal parameters. As we by-pass super, need to do the check and throw ouerselves.
      Parameters:
      c - JComponent
      width - expected ≥ 0
      height - expected ≥ 0
      Throws:
      IllegalArgumentException - if width or height < 0
      NullPointerException - if c == null
    • getBaselineResizeBehavior

      public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
      Overrides:
      getBaselineResizeBehavior in class ComponentUI
    • getPreferredSize

      public Dimension getPreferredSize(JComponent c)

      The preferredSize of the list depends upon the layout orientation. Threre are 3 layouts VERTICAL, HORIZONTAL_WRAP, and VERTICAL_WRAP

      Overrides:
      getPreferredSize in class ComponentUI
      See Also:
    • selectPreviousIndex

      protected void selectPreviousIndex()
      Select the previous row and force it to be visible.
      See Also:
    • selectNextIndex

      protected void selectNextIndex()
      Select the next row and force it to be visible.
      See Also:
    • installKeyboardActions

      protected void installKeyboardActions()
      this method is called at installUI() time.
      Overrides:
      installKeyboardActions in class YListUI
      See Also:
    • uninstallKeyboardActions

      protected void uninstallKeyboardActions()
    • installListeners

      protected void installListeners()
      this method is called at installUI() time.
      Overrides:
      installListeners in class YListUI
      See Also:
    • uninstallListeners

      protected void uninstallListeners()
    • installDefaults

      protected void installDefaults()
      this method is called at installUI() time.
      Overrides:
      installDefaults in class YListUI
      See Also:
    • updateIsFileList

      protected void updateIsFileList()
    • uninstallDefaults

      protected void uninstallDefaults()
    • installUI

      public void installUI(JComponent c)

      Initializes super.list with JComponent c by calling protected void installDefaults() protected void installListeners() protected void installKeyboardActions()

      Initializes super.list with JComponent c by calling protected void installDefaults() protected void installListeners() protected void installKeyboardActions()

      Overrides:
      installUI in class YListUI
    • uninstallUI

      public void uninstallUI(JComponent c)
      Overrides:
      uninstallUI in class ComponentUI
    • getCellBounds

      protected Rectangle getCellBounds(JList<?> list, int index)
      Gets the bounds of the specified model index, returning the resulting bounds, or null if index is not valid.

      with LOG

      Overrides:
      getCellBounds in class YListUI
      Parameters:
      list - JList
      index - int
      Returns:
      Rectangle
    • getHandler

      protected BasicYListUI.Handler getHandler()
    • createMouseInputListener

      protected MouseInputListener createMouseInputListener()
      Creates a delegate that implements MouseInputListener. The delegate is added to the corresponding java.awt.Component listener lists at installUI() time. Subclasses can override this method to return a custom MouseInputListener, e.g.
       class MyListUI extends BasicListUI {
          protected MouseInputListener createMouseInputListener() {
              return new MyMouseInputHandler();
          }
          public class MyMouseInputHandler extends MouseInputHandler {
              public void mouseMoved(MouseEvent e) {
                  // do some extra work when the mouse moves
                  super.mouseMoved(e);
              }
          }
       }
       
      Returns:
      an instance of MouseInputListener
      See Also:
    • createFocusListener

      protected FocusListener createFocusListener()
    • createListSelectionListener

      protected ListSelectionListener createListSelectionListener()
      Creates an instance of ListSelectionHandler that's added to the JLists by selectionModel as needed. Subclasses can override this method to return a custom ListSelectionListener, e.g.
       class MyListUI extends BasicListUI {
          protected ListSelectionListener createListSelectionListener() {
              return new MySelectionListener();
          }
          public class MySelectionListener extends ListSelectionHandler {
              public void valueChanged(ListSelectionEvent e) {
                  // do some extra work when the selection changes
                  super.valueChange(e);
              }
          }
       }
       
      Returns:
      an instance of ListSelectionHandler
      See Also:
    • redrawList

      protected void redrawList()
    • createListDataListener

      protected ListDataListener createListDataListener()
      Creates an instance of ListDataListener that's added to the JLists by model as needed. Subclasses can override this method to return a custom ListDataListener, e.g.
       class MyListUI extends BasicListUI {
          protected ListDataListener createListDataListener() {
              return new MyListDataListener();
          }
          public class MyListDataListener extends ListDataHandler {
              public void contentsChanged(ListDataEvent e) {
                  // do some extra work when the models contents change
                  super.contentsChange(e);
              }
          }
       }
       
      Returns:
      an instance of ListDataListener
      See Also:
    • createPropertyChangeListener

      protected PropertyChangeListener createPropertyChangeListener()
      Creates an instance of PropertyChangeHandler that's added to the JList by installUI(). Subclasses can override this method to return a custom PropertyChangeListener, e.g.
       class MyListUI extends BasicListUI {
          protected PropertyChangeListener createPropertyChangeListener() {
              return new MyPropertyChangeListener();
          }
          public class MyPropertyChangeListener extends PropertyChangeHandler {
              public void propertyChange(PropertyChangeEvent e) {
                  if (e.getPropertyName().equals("model")) {
                      // do some extra work when the model changes
                  }
                  super.propertyChange(e);
              }
          }
       }
       
      Returns:
      an instance of PropertyChangeHandler
      See Also: