JComponentPack 1.5.0

com.zfqjava.swing
Class JListView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.zfqjava.swing.JListView
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class JListView
extends JComponent
implements Accessible

JListView provides a component to diplay more objects from a list.

Support sorting:
In order to support sorting, the TableModel used by JListView should implements ColumnSorter interface.

Client Property:

NameValueDefault Value
JListView.rowSelectionAllowed
  • Boolean.TRUE
  • Boolean.FALSE
Boolean.FALSE
JListView.showVerticalLines
  • Boolean.TRUE
  • Boolean.FALSE
Boolean.FALSE
JListView.showHorizontalLines
  • Boolean.TRUE
  • Boolean.FALSE
Boolean.FALSE
JListView.backgroundImage
  • Image Object
null

See Also:
Serialized Form

Nested Class Summary
static class JListView.AbstractComponentFactory
           
protected  class JListView.AccessibleJListView
          This class implements accessibility support for the JListView class.
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int DETAILS_VIEW_MODE
          Identifies the details view mode.
static int LARGE_ICON_VIEW_MODE
          Identifies the large icon view mode.
static int LIST_VIEW_MODE
          Identifies the list view mode.
static int SMALL_ICON_VIEW_MODE
          Identifies the small icon view mode.
static int THUMBNAILS_VIEW_MODE
          Identifies the thumbnails view mode.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JListView()
          Constructs a JListView with an empty model.
JListView(TableModel model)
          Constructs a JListView with a table model.
JListView(TableModel model, int elementColumnIndex)
          Constructs a JListView with a table model and element column index.
 
Method Summary
 void addActionListener(ActionListener listener)
          Adds an action listener to the JListView.
 void addComponentFactory(String tableModelClassName, String componentFactoryClassName)
          Adds AbstractComponentFactory based the TableModel class name.
 void addListSelectionListener(ListSelectionListener listener)
          Adds a listener to the list that's notified each time a change to the selection occurs.
 void addSelectionInterval(int anchor, int lead)
          Sets the selection to be the union of the specified interval with current selection.
 void cancelEditing()
          Cancels the current editing.
 void clearSelection()
          Clears the selection - after calling this method isSelectionEmpty will return true.
protected  ListSelectionModel createSelectionModel()
          Returns an instance of DefaultListSelectionModel.
 void fireActionPerformed(ActionEvent e)
          Notifies all listeners that have registered interest for notification on this event type.
protected  void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
          Notifies JList ListSelectionListeners that the selection model has changed.
 AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this JListView.
 Action getAction(String name)
          Returns the action for the specified name.
 ActionListener[] getActionListeners()
          Returns an array of all the action listeners registered on this JListView.
 int getAnchorSelectionIndex()
          Returns the first index argument from the most recent addSelectionModel or setSelectionInterval call.
 DefaultCellEditor getCellEditor()
          Retruns the cell editor.
 Dimension getCellPreferredSize(int viewMode)
          Returns the cell preferred size for the specified view mode.
 DefaultCellRenderer getCellRenderer()
          Retruns the cell renderer.
 JListView.AbstractComponentFactory getComponentFactory()
           
 boolean getDragEnabled()
           
 int getEditingIndex()
          Return the index of current editing.
 int getElementColumnIndex()
          Returns the element column index.
 int getLeadSelectionIndex()
          Returns the second index argument from the most recent addSelectionInterval or setSelectionInterval call.
 ListModel getListModel()
          Returns the list view data model as ListModel.
 ListSelectionListener[] getListSelectionListeners()
          Returns an array of all the ListSelectionListeners added to this JList with addListSelectionListener().
 int getMaxSelectionIndex()
          Returns the largest selected cell index.
 int getMinSelectionIndex()
          Returns the smallest selected cell index.
 int getSelectedIndex()
          Returns the first selected index; returns -1 if there is no selected item.
 int[] getSelectedIndices()
          Returns an array of all of the selected indices in increasing order.
 Object getSelectedValue()
          Returns the first selected value, or null if the selection is empty.
 Object[] getSelectedValues()
          Returns an array of the values for the selected cells.
 int getSelectionMode()
          Returns whether single-item or multiple-item selections are allowed.
 ListSelectionModel getSelectionModel()
          Returns the value of the current selection model.
 TableModel getTableModel()
          Returns the list view data model as TableModel.
 ListViewUI getUI()
          Returns the look and feel (L&F) object that renders this component.
 String getUIClassID()
          Returns a string that specifies the name of the L&F class that renders this component.
 boolean getValueIsAdjusting()
          Returns the value of the data model's isAdjusting property.
 int getViewMode()
          Gets the JListView display mode in use.
 boolean isEditing()
          Returns true if the JListView is being edited.
 boolean isSelectedIndex(int index)
          Returns true if the specified index is selected.
 boolean isSelectionEmpty()
          Returns true if nothing is selected.
protected  String paramString()
          Returns a string representation of this JListView.
 void removeActionListener(ActionListener listener)
          Removes the specified action listener from the JListView.
 void removeComponentFactory(String tableModelClassName)
          Removes AbstractComponentFactory based the TableModel class name.
 void removeListSelectionListener(ListSelectionListener listener)
          Removes a listener from the list that's notified each time a change to the selection occurs.
 void removeSelectionInterval(int index0, int index1)
          Sets the selection to be the set difference of the specified interval and the current selection.
 void setCellEditor(DefaultCellEditor editor)
          Sets the editor.
 void setCellPreferredSize(int viewMode, Dimension size)
          Sets the preferred cell size for the specified view mode.
 void setCellRenderer(DefaultCellRenderer renderer)
          Sets the renderer.
 void setComponentFactory(JListView.AbstractComponentFactory componentFactory)
           
 void setDragEnabled(boolean b)
           
 void setListData(TableModel model)
          Sets the list view data use the specified table model.
 void setListData(TableModel model, int elementColumnIndex)
          Sets the list view data use the specified table model and the specified element column index.
 void setSelectedIndex(int index)
          Selects a single cell.
 void setSelectedIndices(int[] indices)
          Selects a set of cells.
 void setSelectionInterval(int anchor, int lead)
          Selects the specified interval.
 void setSelectionMode(int selectionMode)
          Determines whether single-item or multiple-item selections are allowed.
 void setSelectionModel(ListSelectionModel selectionModel)
          Sets the current selection model.
 void setUI(ListViewUI ui)
          Sets the look and feel (L&F) object that renders this component.
 void setValueIsAdjusting(boolean b)
          Sets the data model's isAdjusting property to true, so that a single event will be generated when all of the selection events have finished (for example, when the mouse is being dragged over the list in selection mode).
 void setViewMode(int mode)
          Sets the JListView display mode.
 void sizeColumnWidthToFit(int column)
          Resizes the column width to fit the width of the column contents.
 void startEditingAtIndex(int index)
          Starts the editing at the specified index.
 boolean stopEditing()
          Stops the current editing.
 void updateUI()
          Resets the UI property with a value from the current look and feel.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SMALL_ICON_VIEW_MODE

public static final int SMALL_ICON_VIEW_MODE
Identifies the small icon view mode.

See Also:
Constant Field Values

LARGE_ICON_VIEW_MODE

public static final int LARGE_ICON_VIEW_MODE
Identifies the large icon view mode.

See Also:
Constant Field Values

LIST_VIEW_MODE

public static final int LIST_VIEW_MODE
Identifies the list view mode.

See Also:
Constant Field Values

THUMBNAILS_VIEW_MODE

public static final int THUMBNAILS_VIEW_MODE
Identifies the thumbnails view mode.

See Also:
Constant Field Values

DETAILS_VIEW_MODE

public static final int DETAILS_VIEW_MODE
Identifies the details view mode.

See Also:
Constant Field Values
Constructor Detail

JListView

public JListView()
Constructs a JListView with an empty model.


JListView

public JListView(TableModel model)
Constructs a JListView with a table model.

Parameters:
model - the table model

JListView

public JListView(TableModel model,
                 int elementColumnIndex)
Constructs a JListView with a table model and element column index.

Parameters:
model - the table model
elementColumnIndex - the element column index
Method Detail

updateUI

public void updateUI()
Resets the UI property with a value from the current look and feel.

Overrides:
updateUI in class JComponent
See Also:
JComponent.updateUI()

getUI

public ListViewUI getUI()
Returns the look and feel (L&F) object that renders this component.

Returns:
the ListViewUI object that renders this component

setUI

public void setUI(ListViewUI ui)
Sets the look and feel (L&F) object that renders this component.

Parameters:
ui - the ListViewUI L&F object
See Also:
UIDefaults.getUI(javax.swing.JComponent)

getUIClassID

public String getUIClassID()
Returns a string that specifies the name of the L&F class that renders this component.

Overrides:
getUIClassID in class JComponent
Returns:
"ListViewUI"
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

setDragEnabled

public void setDragEnabled(boolean b)
Since:
ComponentSet 1.8.2

getDragEnabled

public boolean getDragEnabled()
Since:
ComponentSet 1.8.2

createSelectionModel

protected ListSelectionModel createSelectionModel()
Returns an instance of DefaultListSelectionModel. This method is used by the constructor to initialize the selectionModel property.

Returns:
the ListSelectionModel used by this JListView.
See Also:
setSelectionModel(javax.swing.ListSelectionModel), DefaultListSelectionModel

getSelectionModel

public ListSelectionModel getSelectionModel()
Returns the value of the current selection model. The selection model handles the task of making single selections, selections of contiguous ranges, and non-contiguous selections.

Returns:
the ListSelectionModel that implements list selections
See Also:
setSelectionModel(javax.swing.ListSelectionModel), ListSelectionModel

setSelectionModel

public void setSelectionModel(ListSelectionModel selectionModel)
Sets the current selection model. The selection model handles the task of making single selections, selections of contiguous ranges, and non-contiguous selections.

Parameters:
selectionModel - the ListSelectionModel that implements list selections
See Also:
getSelectionModel()

setViewMode

public void setViewMode(int mode)
Sets the JListView display mode.

Parameters:
mode - one of 5 legal values:
  • JListView.SMALL_ICON_VIEW_MODE
  • JListView.LARGE_ICON_VIEW_MODE
  • JListView.LIST_VIEW_MODE
  • JListView.DETAILS_VIEW_MODE
  • JListView.THUMBNAILS_VIEW_MODE
Throws:
IllegalArgumentException - if the mode illegal

getViewMode

public int getViewMode()
Gets the JListView display mode in use.

Returns:
the display mode in use, one of 5 legal values:
  • JListView.SMALL_ICON_VIEW_MODE
  • JListView.LARGE_ICON_VIEW_MODE
  • JListView.LIST_VIEW_MODE
  • JListView.DETAILS_VIEW_MODE
  • JListView.THUMBNAILS_VIEW_MODE

setCellPreferredSize

public void setCellPreferredSize(int viewMode,
                                 Dimension size)
Sets the preferred cell size for the specified view mode.

Parameters:
viewMode - the view mode, one of 5 legal values:
  • JListView.SMALL_ICON_VIEW_MODE
  • JListView.LARGE_ICON_VIEW_MODE
  • JListView.LIST_VIEW_MODE
  • JListView.DETAILS_VIEW_MODE
  • JListView.THUMBNAILS_VIEW_MODE
size - the preferred cell size
Throws:
IllegalArgumentException - if the viewMode illegal
Since:
JListView 1.4
See Also:
getCellPreferredSize(int)

getCellPreferredSize

public Dimension getCellPreferredSize(int viewMode)
Returns the cell preferred size for the specified view mode.

Parameters:
viewMode - the view mode, one of 5 legal values:
  • JListView.SMALL_ICON_VIEW_MODE
  • JListView.LARGE_ICON_VIEW_MODE
  • JListView.LIST_VIEW_MODE
  • JListView.DETAILS_VIEW_MODE
  • JListView.THUMBNAILS_VIEW_MODE
Returns:
the preferred cell size
Throws:
IllegalArgumentException - if the viewMode illegal
Since:
JListView 1.4
See Also:
setCellPreferredSize(int, java.awt.Dimension)

setCellRenderer

public void setCellRenderer(DefaultCellRenderer renderer)
Sets the renderer.

Parameters:
renderer - the cell renderer

getCellRenderer

public DefaultCellRenderer getCellRenderer()
Retruns the cell renderer.

Returns:
the cell renderer

setCellEditor

public void setCellEditor(DefaultCellEditor editor)
Sets the editor.

Parameters:
editor - the cell editor

getCellEditor

public DefaultCellEditor getCellEditor()
Retruns the cell editor.

Returns:
the cell editor

getAction

public Action getAction(String name)
Returns the action for the specified name.

Parameters:
name - the action name
Returns:
the action
Since:
JComponentPack 1.4.0

addComponentFactory

public void addComponentFactory(String tableModelClassName,
                                String componentFactoryClassName)
Adds AbstractComponentFactory based the TableModel class name.

Parameters:
tableModelClassName - the table model class name
componentFactoryClassName - the AbstractComponentFactory class name
Since:
JComponentPack 1.4.0

removeComponentFactory

public void removeComponentFactory(String tableModelClassName)
Removes AbstractComponentFactory based the TableModel class name.

Parameters:
tableModelClassName - the table model class name
Since:
JComponentPack 1.4.0

getComponentFactory

public JListView.AbstractComponentFactory getComponentFactory()
Since:
JComponentPack 1.4.0

setComponentFactory

public void setComponentFactory(JListView.AbstractComponentFactory componentFactory)
Since:
JComponentPack 1.4.0

setListData

public void setListData(TableModel model)
Sets the list view data use the specified table model. The default element column index is 0.

Parameters:
model - the list view data
See Also:
setListData(TableModel,int)

setListData

public void setListData(TableModel model,
                        int elementColumnIndex)
Sets the list view data use the specified table model and the specified element column index.

Parameters:
model - the list view data
elementColumnIndex - the element column index
See Also:
setListData(TableModel)

getTableModel

public TableModel getTableModel()
Returns the list view data model as TableModel.

Returns:
the list view data model as TableModel.

getListModel

public ListModel getListModel()
Returns the list view data model as ListModel. This will auto create when setListData invoke.

Returns:
the list view data model as ListModel.

getElementColumnIndex

public int getElementColumnIndex()
Returns the element column index.

Returns:
the element column index

sizeColumnWidthToFit

public void sizeColumnWidthToFit(int column)
Resizes the column width to fit the width of the column contents.

Parameters:
column - the column
Since:
JComponentPack 1.4.0

setSelectionMode

public void setSelectionMode(int selectionMode)
Determines whether single-item or multiple-item selections are allowed. The following selectionMode values are allowed:
  • ListSelectionModel.SINGLE_SELECTION Only one list index can be selected at a time. In this mode the setSelectionInterval and addSelectionInterval methods are equivalent, and only the second index argument is used.
  • ListSelectionModel.SINGLE_INTERVAL_SELECTION One contiguous index interval can be selected at a time. In this mode setSelectionInterval and addSelectionInterval are equivalent.
  • ListSelectionModel.MULTIPLE_INTERVAL_SELECTION In this mode, there's no restriction on what can be selected. This is the default.

Parameters:
selectionMode - an integer specifying the type of selections that are permissible
See Also:
getSelectionMode()

getSelectionMode

public int getSelectionMode()
Returns whether single-item or multiple-item selections are allowed.

Returns:
the value of the selectionMode property
See Also:
setSelectionMode(int)

getAnchorSelectionIndex

public int getAnchorSelectionIndex()
Returns the first index argument from the most recent addSelectionModel or setSelectionInterval call. This is a convenience method that just delegates to the selectionModel.

Returns:
the index that most recently anchored an interval selection
See Also:
ListSelectionModel.getAnchorSelectionIndex(), addSelectionInterval(int, int), setSelectionInterval(int, int), addListSelectionListener(javax.swing.event.ListSelectionListener)

getLeadSelectionIndex

public int getLeadSelectionIndex()
Returns the second index argument from the most recent addSelectionInterval or setSelectionInterval call. This is a convenience method that just delegates to the selectionModel.

Returns:
the index that most recently ended a interval selection
See Also:
ListSelectionModel.getLeadSelectionIndex(), addSelectionInterval(int, int), setSelectionInterval(int, int), addListSelectionListener(javax.swing.event.ListSelectionListener)

getMinSelectionIndex

public int getMinSelectionIndex()
Returns the smallest selected cell index. This is a convenience method that just delegates to the selectionModel.

Returns:
the smallest selected cell index
See Also:
ListSelectionModel.getMinSelectionIndex(), addListSelectionListener(javax.swing.event.ListSelectionListener)

getMaxSelectionIndex

public int getMaxSelectionIndex()
Returns the largest selected cell index. This is a convenience method that just delegates to the selectionModel.

Returns:
the largest selected cell index
See Also:
ListSelectionModel.getMaxSelectionIndex(), addListSelectionListener(javax.swing.event.ListSelectionListener)

isSelectedIndex

public boolean isSelectedIndex(int index)
Returns true if the specified index is selected. This is a convenience method that just delegates to the selectionModel.

Parameters:
index - index to be queried for selection state
Returns:
true if the specified index is selected
See Also:
ListSelectionModel.isSelectedIndex(int), setSelectedIndex(int), addListSelectionListener(javax.swing.event.ListSelectionListener)

isSelectionEmpty

public boolean isSelectionEmpty()
Returns true if nothing is selected. This is a convenience method that just delegates to the selectionModel.

Returns:
true if nothing is selected
See Also:
ListSelectionModel.isSelectionEmpty(), clearSelection(), addListSelectionListener(javax.swing.event.ListSelectionListener)

clearSelection

public void clearSelection()
Clears the selection - after calling this method isSelectionEmpty will return true. This is a convenience method that just delegates to the selectionModel.

See Also:
ListSelectionModel.clearSelection(), isSelectionEmpty(), addListSelectionListener(javax.swing.event.ListSelectionListener)

setSelectionInterval

public void setSelectionInterval(int anchor,
                                 int lead)
Selects the specified interval. Both the anchor and lead indices are included. It's not necessary for anchor to be less than lead. This is a convenience method that just delegates to the selectionModel. The DefaultListSelectionModel implementation will do nothing if either anchor or lead are -1. If anchor or lead are less than -1, IndexOutOfBoundsException is thrown.

Parameters:
anchor - the first index to select
lead - the last index to select
Throws:
IndexOutOfBoundsException - if either anchor or lead are less than -1
See Also:
ListSelectionModel.setSelectionInterval(int, int), addSelectionInterval(int, int), removeSelectionInterval(int, int), addListSelectionListener(javax.swing.event.ListSelectionListener)

addSelectionInterval

public void addSelectionInterval(int anchor,
                                 int lead)
Sets the selection to be the union of the specified interval with current selection. Both the anchor and lead indices are included. It's not necessary for anchor to be less than lead. This is a convenience method that just delegates to the selectionModel. The DefaultListSelectionModel implementation will do nothing if either anchor or lead are -1. If anchor or lead are less than -1, IndexOutOfBoundsException is thrown.

Parameters:
anchor - the first index to add to the selection
lead - the last index to add to the selection
Throws:
IndexOutOfBoundsException - if either anchor or lead are less than -1
See Also:
ListSelectionModel.addSelectionInterval(int, int), setSelectionInterval(int, int), removeSelectionInterval(int, int), addListSelectionListener(javax.swing.event.ListSelectionListener)

removeSelectionInterval

public void removeSelectionInterval(int index0,
                                    int index1)
Sets the selection to be the set difference of the specified interval and the current selection. Both the index0 and index1 indices are removed. It's not necessary for index0 to be less than index1. This is a convenience method that just delegates to the selectionModel. The DefaultListSelectionModel implementation will do nothing if either index0 or index1 are -1. If index0 or index1 are less than -1, IndexOutOfBoundsException is thrown.

Parameters:
index0 - the first index to remove from the selection
index1 - the last index to remove from the selection
Throws:
IndexOutOfBoundsException - if either index0 or index1 are less than -1
See Also:
ListSelectionModel.removeSelectionInterval(int, int), setSelectionInterval(int, int), addSelectionInterval(int, int), addListSelectionListener(javax.swing.event.ListSelectionListener)

setValueIsAdjusting

public void setValueIsAdjusting(boolean b)
Sets the data model's isAdjusting property to true, so that a single event will be generated when all of the selection events have finished (for example, when the mouse is being dragged over the list in selection mode).

Parameters:
b - the boolean value for the property value
See Also:
ListSelectionModel.setValueIsAdjusting(boolean)

getValueIsAdjusting

public boolean getValueIsAdjusting()
Returns the value of the data model's isAdjusting property. This value is true if multiple changes are being made.

Returns:
true if multiple selection-changes are occurring, as when the mouse is being dragged over the list
See Also:
ListSelectionModel.getValueIsAdjusting()

setSelectedIndex

public void setSelectedIndex(int index)
Selects a single cell.

Parameters:
index - the index of the one cell to select
See Also:
ListSelectionModel.setSelectionInterval(int, int), isSelectedIndex(int), addListSelectionListener(javax.swing.event.ListSelectionListener)

getSelectedIndex

public int getSelectedIndex()
Returns the first selected index; returns -1 if there is no selected item.

Returns:
the value of getMinSelectionIndex
See Also:
getMinSelectionIndex(), addListSelectionListener(javax.swing.event.ListSelectionListener)

setSelectedIndices

public void setSelectedIndices(int[] indices)
Selects a set of cells.

Parameters:
indices - an array of the indices of the cells to select
See Also:
ListSelectionModel.addSelectionInterval(int, int), isSelectedIndex(int), addListSelectionListener(javax.swing.event.ListSelectionListener)

getSelectedIndices

public int[] getSelectedIndices()
Returns an array of all of the selected indices in increasing order.

Returns:
all of the selected indices, in increasing order
See Also:
removeSelectionInterval(int, int), addListSelectionListener(javax.swing.event.ListSelectionListener)

getSelectedValues

public Object[] getSelectedValues()
Returns an array of the values for the selected cells. The returned values are sorted in increasing index order.

Returns:
the selected values or an empty list if nothing is selected
See Also:
isSelectedIndex(int), getListModel(), addListSelectionListener(javax.swing.event.ListSelectionListener)

getSelectedValue

public Object getSelectedValue()
Returns the first selected value, or null if the selection is empty.

Returns:
the first selected value
See Also:
getMinSelectionIndex(), getListModel(), addListSelectionListener(javax.swing.event.ListSelectionListener)

isEditing

public boolean isEditing()
Returns true if the JListView is being edited.

Returns:
true if the JListView is being edited, otherwise return false

stopEditing

public boolean stopEditing()
Stops the current editing.

Returns:
true if the editing is stoped, otherwise return false

cancelEditing

public void cancelEditing()
Cancels the current editing.


startEditingAtIndex

public void startEditingAtIndex(int index)
Starts the editing at the specified index.

Parameters:
index - the specified index

getEditingIndex

public int getEditingIndex()
Return the index of current editing.

Returns:
the index of current editing

addActionListener

public void addActionListener(ActionListener listener)
Adds an action listener to the JListView.

Parameters:
listener - the listener to add
See Also:
JListView(javax.swing.table.TableModel, int)

removeActionListener

public void removeActionListener(ActionListener listener)
Removes the specified action listener from the JListView.

Parameters:
listener - the listener to remove

getActionListeners

public ActionListener[] getActionListeners()
Returns an array of all the action listeners registered on this JListView.

Returns:
all of the JListView's ActionListeners or an empty array if no action listeners are currently registered
See Also:
addActionListener(java.awt.event.ActionListener), removeActionListener(java.awt.event.ActionListener)

fireActionPerformed

public void fireActionPerformed(ActionEvent e)
Notifies all listeners that have registered interest for notification on this event type.

Parameters:
e - the action event to fire
See Also:
EventListenerList

addListSelectionListener

public void addListSelectionListener(ListSelectionListener listener)
Adds a listener to the list that's notified each time a change to the selection occurs. Listeners added directly to the JListView will have their ListSelectionEvent.getSource() == this JListView (instead of the ListSelectionModel).

Parameters:
listener - the ListSelectionListener to add
See Also:
getSelectionModel(), getListSelectionListeners()

removeListSelectionListener

public void removeListSelectionListener(ListSelectionListener listener)
Removes a listener from the list that's notified each time a change to the selection occurs.

Parameters:
listener - the ListSelectionListener to remove
See Also:
addListSelectionListener(javax.swing.event.ListSelectionListener), getSelectionModel()

getListSelectionListeners

public ListSelectionListener[] getListSelectionListeners()
Returns an array of all the ListSelectionListeners added to this JList with addListSelectionListener().

Returns:
all of the ListSelectionListeners added or an empty array if no listeners have been added
See Also:
addListSelectionListener(javax.swing.event.ListSelectionListener)

fireSelectionValueChanged

protected void fireSelectionValueChanged(int firstIndex,
                                         int lastIndex,
                                         boolean isAdjusting)
Notifies JList ListSelectionListeners that the selection model has changed. It's used to forward ListSelectionEvents from the selectionModel to the ListSelectionListeners added directly to the JList.

Parameters:
firstIndex - the first selected index
lastIndex - the last selected index
isAdjusting - true if multiple changes are being made
See Also:
addListSelectionListener(javax.swing.event.ListSelectionListener), removeListSelectionListener(javax.swing.event.ListSelectionListener), EventListenerList

paramString

protected String paramString()
Returns a string representation of this JListView. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Overrides:
paramString in class JComponent
Returns:
a string representation of this JListView.

getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JListView. For JListViews, the AccessibleContext takes the form of an AccessibleJListView. A new AccessibleJListView instance is created if necessary.

Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JComponent
Returns:
an AccessibleJListView that serves as the AccessibleContext of this JListView

JComponentPack 1.5.0

Send your Feedback
JComponentPack 1.5.0
Copyright © 2001-2007 Extreme Component, Inc. All rights reserved.