Class JList<E>

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class JList<E> extends JComponent implements Scrollable, Accessible
Emulator for JList, over an SJList peer that renders the Grid<Integer> (SD_sjlist). R_leaf_peer_lockdown-locked-down (JDK leaf — private peer ctor). Implements Scrollable and Accessible to match the JDK interface set.

The list owns its state, as the JDK's does: dataModel and selectionModel are this class's fields, the selection methods are the JDK's bodies over them, and no getter reads the peer (D_emulator_owned_state). The surrogate shares both model objects, pushed to it through withPeer: it renders the model, mirrors the selection onto the Grid, and writes a browser selection into the selection model. It also shifts the selection when the model inserts or removes rows, which is the JDK's BasicListUI behaviour, not JList's. The selection reaches this class's listeners the JDK's way: a ListSelectionHandler on the selection model, registered by the first addListSelectionListener(ListSelectionListener).

Item clicks come from a ctor-installed bridge re-sourcing the surrogate's SMouseListener with source rebound to this, so addMouseListener + getClickCount()==2 + locationToIndex works as written. The JDK ListCellRenderer surface lives here; a dynamic Vaadin renderer on the surrogate resolves it per render call and snapshots the result (D_event_port_policy / D_jcombobox / R_vaadin_first). See installSurrogateBridges() / renderCellViaEmulator(Integer).

See Also:
  • Field Details

  • Constructor Details

    • JList

      public JList()
    • JList

      public JList(ListModel<E> dataModel)
      The root ctor, and the only one naming the peer: R_leaf_peer_lockdown lock-down (JDK leaf — no protected (Component) ctor).
      Throws:
      IllegalArgumentException - if dataModel is null, as in the JDK
    • JList

      public JList(E[] listData)
    • JList

      public JList(Vector<E> listData)
  • Method Details

    • getModel

      public ListModel<E> getModel()
    • setModel

      public void setModel(ListModel<E> model)
    • setListData

      public void setListData(E[] listData)
    • setListData

      public void setListData(Vector<E> listData)
    • getCellRenderer

      public ListCellRenderer<? super E> getCellRenderer()
    • setCellRenderer

      public void setCellRenderer(ListCellRenderer<? super E> cellRenderer)
    • createSelectionModel

      protected ListSelectionModel createSelectionModel()
      Returns a fresh DefaultListSelectionModel; a subclass overrides this to install its own.
    • getSelectionModel

      public ListSelectionModel getSelectionModel()
    • setSelectionModel

      public void setSelectionModel(ListSelectionModel selectionModel)
    • setSelectionMode

      public void setSelectionMode(int selectionMode)
    • getSelectionMode

      public int getSelectionMode()
    • getAnchorSelectionIndex

      public int getAnchorSelectionIndex()
    • getLeadSelectionIndex

      public int getLeadSelectionIndex()
    • getMinSelectionIndex

      public int getMinSelectionIndex()
    • getMaxSelectionIndex

      public int getMaxSelectionIndex()
    • isSelectedIndex

      public boolean isSelectedIndex(int index)
    • isSelectionEmpty

      public boolean isSelectionEmpty()
    • clearSelection

      public void clearSelection()
    • setSelectionInterval

      public void setSelectionInterval(int anchor, int lead)
    • addSelectionInterval

      public void addSelectionInterval(int anchor, int lead)
    • removeSelectionInterval

      public void removeSelectionInterval(int index0, int index1)
    • setValueIsAdjusting

      public void setValueIsAdjusting(boolean b)
    • getValueIsAdjusting

      public boolean getValueIsAdjusting()
    • getSelectedIndices

      public int[] getSelectedIndices()
    • setSelectedIndex

      public void setSelectedIndex(int index)
      An index below 0 does not clear the selection: DefaultListSelectionModel ignores it, as in the JDK.
    • setSelectedIndices

      public void setSelectedIndices(int[] indices)
    • getSelectedValuesList

      public List<E> getSelectedValuesList()
    • getSelectedIndex

      public int getSelectedIndex()
    • getSelectedValue

      public E getSelectedValue()
    • setSelectedValue

      public void setSelectedValue(Object anObject, boolean shouldScroll)
      A value that is already selected, or that the model does not hold, leaves the selection as it is: the JDK's fallback setSelectedIndex(-1) is ignored by the selection model.
    • ensureIndexIsVisible

      public void ensureIndexIsVisible(int index)
      Scrolls the Grid to the row; the JDK's getCellBounds route has no server-side geometry here.
    • addListSelectionListener

      public void addListSelectionListener(ListSelectionListener listener)
    • removeListSelectionListener

      public void removeListSelectionListener(ListSelectionListener listener)
    • getListSelectionListeners

      public ListSelectionListener[] getListSelectionListeners()
    • fireSelectionValueChanged

      protected void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
    • locationToIndex

      public int locationToIndex(Point location)
      The clicked row during a mouse handler's dispatch, -1 otherwise, whatever the coordinates: there is no server-side pixel→cell map (R_layouts_close_enough).

      As BasicListUI's, a null location throws and the answer is the closest cell: a list shrunk while the handler was parked on a dialog answers its last row.

    • indexToLocation

      public Point indexToLocation(int index)
    • getCellBounds

      public Rectangle getCellBounds(int index0, int index1)
    • getLayoutOrientation

      public int getLayoutOrientation()
    • setLayoutOrientation

      public void setLayoutOrientation(int layoutOrientation)
    • getVisibleRowCount

      public int getVisibleRowCount()
    • setVisibleRowCount

      public void setVisibleRowCount(int visibleRowCount)
    • getFixedCellWidth

      public int getFixedCellWidth()
    • setFixedCellWidth

      public void setFixedCellWidth(int width)
    • getFixedCellHeight

      public int getFixedCellHeight()
    • setFixedCellHeight

      public void setFixedCellHeight(int height)
    • getPrototypeCellValue

      public E getPrototypeCellValue()
    • setPrototypeCellValue

      public void setPrototypeCellValue(E prototypeCellValue)
      Fires "prototypeCellValue" on this emulator in addition to delegating. The surrogate fires on its own listener list, which a migrator's addPropertyChangeListener on the JList never reaches — the two-layer fan-out is independent by design (D_owed_events).
    • getSelectionForeground

      public Color getSelectionForeground()
    • setSelectionForeground

      public void setSelectionForeground(Color c)
    • getSelectionBackground

      public Color getSelectionBackground()
    • setSelectionBackground

      public void setSelectionBackground(Color c)
    • getDragEnabled

      public boolean getDragEnabled()
    • setDragEnabled

      public void setDragEnabled(boolean b)
    • getDropMode

      public final DropMode getDropMode()
    • setDropMode

      public final void setDropMode(DropMode dropMode)
    • getFirstVisibleIndex

      public int getFirstVisibleIndex()
    • getLastVisibleIndex

      public int getLastVisibleIndex()
    • getPreferredScrollableViewportSize

      public Dimension getPreferredScrollableViewportSize()
      Specified by:
      getPreferredScrollableViewportSize in interface Scrollable
    • getScrollableUnitIncrement

      public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
      Specified by:
      getScrollableUnitIncrement in interface Scrollable
    • getScrollableBlockIncrement

      public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
      Specified by:
      getScrollableBlockIncrement in interface Scrollable
    • getScrollableTracksViewportWidth

      public boolean getScrollableTracksViewportWidth()
      Specified by:
      getScrollableTracksViewportWidth in interface Scrollable
    • getScrollableTracksViewportHeight

      public boolean getScrollableTracksViewportHeight()
      Specified by:
      getScrollableTracksViewportHeight in interface Scrollable
    • getUIClassID

      public String getUIClassID()
      Overrides:
      getUIClassID in class JComponent
    • updateUI

      public void updateUI()
      Overrides:
      updateUI in class JComponent
    • getUI

      public ListUI getUI()
      Overrides:
      getUI in class JComponent
    • setUI

      public void setUI(ListUI ui)
    • getAccessibleContext

      public AccessibleContext getAccessibleContext()
      Specified by:
      getAccessibleContext in interface Accessible
      Overrides:
      getAccessibleContext in class Component