juife
v0.1a

net.sf.juife
Class ComponentList

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by net.sf.juife.ComponentList
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class ComponentList
extends javax.swing.JPanel

A component that contains a list of components and allows the user to select one or more of them.

Note that if you want to create a list of non-interactive components that just show some kind of information consider using JList. In JList this can be done by setting a custom delegate to paint the cells using JList.setCellRenderer(javax.swing.ListCellRenderer) method.

See Also:
ComponentListModel, DefaultComponentListModel, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
ComponentList()
          Creates a new instance of ComponentList
ComponentList(ComponentListModel model)
          Creates a new instance of ComponentList with the specified data model.
 
Method Summary
 void addListSelectionListener(javax.swing.event.ListSelectionListener listener)
          Registers the specified listener for receiving list selection events.
 void clearSelection()
          Clears the selection.
 void ensureIndexIsVisible(int index)
          Scrolls the viewport to make the specified component visible.
protected  void fireSelectionChanged(javax.swing.event.ListSelectionEvent e)
          Notifies ComponentList ListSelectionListeners that the selection model has changed.
 void fireSelectionProbablyChanged(int index)
          Notifies all listeners that have registered interest for notification on this event type.
 int getMaxSelectionIndex()
          Gets the last selected index or -1 if the selection is empty.
 int getMinSelectionIndex()
          Gets the first selected index or -1 if the selection is empty.
 ComponentListModel getModel()
          Gets the data model of this list.
 java.awt.Component[] getSelectedComponents()
          Gets all selected components.
 int[] getSelectedIndices()
          Getss an array of all of the selected indices in increasing order.
 int getSelectionMode()
          Gets the selection mode.
 javax.swing.ListSelectionModel getSelectionModel()
          Gets the current selection model of this list.
 ComponentListUI getUI()
          Gets the L&F object that renders this component.
 java.lang.String getUIClassID()
          Gets a string that specifies the name of the L&F class that renders this component.
 boolean isSelectedIndex(int index)
          Determines whether the specified index is selected.
 boolean isSelectionEmpty()
          Determines whether the selection is empty.
 void removeListSelectionListener(javax.swing.event.ListSelectionListener listener)
          Removes the specified listener.
 void selectAll()
          Selects all components in the list.
 void setModel(ComponentListModel model)
          Sets the data model of the list.
 void setSelectedComponent(java.awt.Component c, boolean shouldScroll)
          Selects the specified component.
 void setSelectedIndex(int index)
          Selects the component at the specified index.
 void setSelectedIndices(int[] indices)
          Selects the components with the specified indices.
 void setSelectionInterval(int index0, int index1)
          Changes the selection to be between index0 and index1 inclusive.
 void setSelectionMode(int selectionMode)
          Sets the selection mode.
 void setSelectionModel(javax.swing.ListSelectionModel model)
          Sets the selection model of this list.
 void setUI(ComponentListUI ui)
          Sets the L&F object that renders this component.
 void updateUI()
          Resets the UI property to a value from the current look and feel.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, paramString, setUI
 
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, 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, 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
 

Constructor Detail

ComponentList

public ComponentList()
Creates a new instance of ComponentList


ComponentList

public ComponentList(ComponentListModel model)
Creates a new instance of ComponentList with the specified data model.

Parameters:
model - The data model for this ComponentList instance.
Method Detail

getUIClassID

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

Overrides:
getUIClassID in class javax.swing.JPanel
Returns:
the string "ComponentListUI"

getUI

public ComponentListUI getUI()
Gets the L&F object that renders this component.

Overrides:
getUI in class javax.swing.JPanel
Returns:
The L&F object that renders this component.

setUI

public void setUI(ComponentListUI ui)
Sets the L&F object that renders this component.

Parameters:
ui - The new UI delegate.

updateUI

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

Overrides:
updateUI in class javax.swing.JPanel

addListSelectionListener

public void addListSelectionListener(javax.swing.event.ListSelectionListener listener)
Registers the specified listener for receiving list selection events.

Parameters:
listener - The ListSelectionListener to register.

removeListSelectionListener

public void removeListSelectionListener(javax.swing.event.ListSelectionListener listener)
Removes the specified listener.

Parameters:
listener - The ListSelectionListener to remove.

fireSelectionChanged

protected void fireSelectionChanged(javax.swing.event.ListSelectionEvent e)
Notifies ComponentList ListSelectionListeners that the selection model has changed.


getModel

public ComponentListModel getModel()
Gets the data model of this list.

Returns:
The data model of this list.

setModel

public void setModel(ComponentListModel model)
Sets the data model of the list.

Parameters:
model - The new data model.

getSelectionModel

public javax.swing.ListSelectionModel getSelectionModel()
Gets the current selection model of this list.

Returns:
The current selection model of this list.

setSelectionModel

public void setSelectionModel(javax.swing.ListSelectionModel model)
Sets the selection model of this list.

Parameters:
model - The new selection model.

getSelectionMode

public int getSelectionMode()
Gets the selection mode.

Returns:
The selection mode.
See Also:
setSelectionMode(int), ListSelectionModel.getSelectionMode()

setSelectionMode

public void setSelectionMode(int selectionMode)
Sets the selection mode.

See Also:
ListSelectionModel.setSelectionMode(int), getSelectionMode()

setSelectionInterval

public void setSelectionInterval(int index0,
                                 int index1)
Changes the selection to be between index0 and index1 inclusive.

See Also:
ListSelectionModel.setSelectionInterval(int, int)

getMinSelectionIndex

public int getMinSelectionIndex()
Gets the first selected index or -1 if the selection is empty.

Returns:
The first selected index or -1 if the selection is empty.
See Also:
ListSelectionModel.getMinSelectionIndex()

getMaxSelectionIndex

public int getMaxSelectionIndex()
Gets the last selected index or -1 if the selection is empty.

Returns:
The last selected index or -1 if the selection is empty.
See Also:
ListSelectionModel.getMaxSelectionIndex()

isSelectionEmpty

public boolean isSelectionEmpty()
Determines whether the selection is empty.

Returns:
true if nothing is selected.
See Also:
ListSelectionModel.isSelectionEmpty()

isSelectedIndex

public boolean isSelectedIndex(int index)
Determines whether the specified index is selected.

Returns:
true if the specified index is selected, false otherwise.
See Also:
ListSelectionModel.isSelectedIndex(int)

setSelectedIndex

public void setSelectedIndex(int index)
Selects the component at the specified index.

Parameters:
index - The position of the component to be selected.

getSelectedIndices

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

Returns:
An array of all of the selected indices in increasing order.

setSelectedIndices

public void setSelectedIndices(int[] indices)
Selects the components with the specified indices.

Parameters:
indices - An array of the indices of the components to be selected.

getSelectedComponents

public java.awt.Component[] getSelectedComponents()
Gets all selected components. The returned components are sorted in increasing index order.

Returns:
An array of all selected components.

setSelectedComponent

public void setSelectedComponent(java.awt.Component c,
                                 boolean shouldScroll)
Selects the specified component.

Parameters:
c - The component to be selected.
shouldScroll - Determines whether the list should scroll to display the selected component; true if the list should scroll to display the selected component, false otherwise.

selectAll

public void selectAll()
Selects all components in the list.


clearSelection

public void clearSelection()
Clears the selection.

See Also:
ListSelectionModel.clearSelection()

ensureIndexIsVisible

public void ensureIndexIsVisible(int index)
Scrolls the viewport to make the specified component visible.

Parameters:
index - The index of the component to make visible.

fireSelectionProbablyChanged

public void fireSelectionProbablyChanged(int index)
Notifies all listeners that have registered interest for notification on this event type.


juife
v0.1a

Copyright © 2005 Grigor Iliev. All rights reserved. SourceForge.net Logo