JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.swing
Class JCMultiSelectList

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.klg.jclass.swing.JCMultiSelectList
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class JCMultiSelectList
extends JComponent
implements Serializable

JCMultiSelectList matches the API for JList, except that two lists instead of one appear in the component’s GUI. There are buttons between the two lists that move items back and forth.

See Also:
Serialized Form

Nested Class Summary
protected  class JCMultiSelectList.JCFixedCenterLayout
          Internal layout.
protected  class JCMultiSelectList.MultiSelectListUI
           
protected  class JCMultiSelectList.SelectionButton
          Internal selection button class.
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  JPanel buttonPanel
           
protected  Dimension defaultListSize
           
protected static String DESELECT_ALL
           
protected static String DESELECT_ITEM
           
protected  JCMultiSelectList.SelectionButton deselectAllButton
           
protected  JCMultiSelectList.SelectionButton deselectItemButton
           
protected  com.klg.jclass.swing.JCMultiSelectList.EventHandler eventHandler
           
protected  FontMetrics lastFontMetrics
           
protected  JList mainList
           
protected static String SELECT_ALL
           
protected static String SELECT_ITEM
           
protected  JCMultiSelectList.SelectionButton selectAllButton
           
protected  JList selectionList
           
protected  JScrollPane selectionPane
           
protected  JCMultiSelectList.SelectionButton selectItemButton
           
protected  JList sourceList
           
protected  JScrollPane sourcePane
           
 
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
JCMultiSelectList()
          Creates a new JCMultiSelectList component with an empty model.
JCMultiSelectList(int hgap)
          Creates a new JCMultiSelectList component with an empty model and the specified horizontal gap between components.
JCMultiSelectList(ListModel dataModel)
          Constructs a JCMultiSelectList that displays the elements in the specified non-null model.
JCMultiSelectList(Object[] listData)
          Constructs a JCMultiSelectList that displays the elements in the specified array.
JCMultiSelectList(Vector listData)
          Constructs a JCMultiSelectList that displays the elements in the specified Vector.
 
Method Summary
 void addListSelectionListener(ListSelectionListener listener)
          Adds a listener to the ListSelectionListeners list.
 void addSelectionInterval(int anchor, int lead)
          Adds the specified interval to the current selection.
 void clearSelection()
          Clears the selection.
protected  void deselectAll()
          Moves all items from the right list to the left list.
protected  void deselectItem()
          Moves the items selected in the right list to the left list.
protected  void disableButtons()
          Disables all the buttons.
protected  void doUpdate(JList list, Object[] values, int[] newIndices)
          Move the selected items from one list and also selects the next item in the list.
protected  void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
          Forwards the given notification event to all registered listeners.
 String getAbout()
          Returns vendor information.
 int getAnchorSelectionIndex()
          Returns the first index argument from the most recent interval selection.
static Dimension getButtonSize()
          Returns the nominal size of the component.
 ListCellRenderer getCellRenderer()
          Returns the renderer that's used to paint each cell.
 int getFixedCellHeight()
          Returns the fixed cell height.
 int getFixedCellWidth()
          Returns the fixed cell width.
 int getIndexFromItem(JList list, Object item)
          Given an Object, finds its index in the list.
 int getLeadSelectionIndex()
          Returns the second index argument from the most recent interval selection.
 int getListPreferredWidth()
          Returns the preferred width of the list.
 Dimension getMaximumSize()
          Returns the maximum size of the component.
 int getMaxSelectionIndex()
          Returns the maximal selected cell index.
 Dimension getMinimumSize()
          Returns the minimum size of the component.
 int getMinSelectionIndex()
          Returns the minimal selected cell index.
 ListModel getModel()
          Returns the list's data model.
 Dimension getPreferredSize()
          Returns the preferred size of the component.
 Object getPrototypeCellValue()
          Returns the cell size based on an estimate of the cell's width and height.
 int getSelectedIndex()
          Returns the first selected cell index.
 int[] getSelectedIndices()
          Returns the selected indices array.
 Object getSelectedValue()
          Returns the first selected cell value.
 Object[] getSelectedValues()
          Returns an array of the selected cell values.
 Color getSelectionBackground()
          Returns the background color for selected cells.
 Color getSelectionForeground()
          Returns the foreground color for selected cells.
 int getSelectionMode()
          Returns the selectionMode property value.
 ListSelectionModel getSelectionModel()
          Returns the current selection model.
 String getUIClassID()
          Returns the name of the UIFactory for this component.
protected  void init()
          Initializes the component after it is created.
protected  JCMultiSelectList.SelectionButton initButton(JCMultiSelectList.SelectionButton button, String toolTipText)
          Initializes and adds a button to the component.
 boolean isSelectedIndex(int index)
          Returns true if the specified index is selected.
 boolean isSelectionEmpty()
          Returns true if nothing is selected.
 void paint(Graphics g)
           
protected  String paramString()
          Returns a String representation of the object.
 void removeListSelectionListener(ListSelectionListener listener)
          Removes a listener from the the ListSelectionListeners list.
 void removeSelectionInterval(int index0, int index1)
          Removes the specified interval to the current selection.
protected  void selectAll()
          Moves all items from the left list to the right list.
protected  void selectItem()
          Moves the items selected in the left list to the right list.
 void setAbout(String s)
          Provided for Beans property editors - has no effect.
 void setCellRenderer(ListCellRenderer cellRenderer)
          Sets the renderer that's used to paint each cell.
 void setEnabled(boolean b)
          Enables, disables this component and its subcomponents.
 void setFixedCellHeight(int height)
          Sets the fixed cell height.
 void setFixedCellWidth(int width)
          Sets the fixed cell width.
 void setListData(Object[] listData)
          Constructs the list's data model from an array of Objects.
 void setListData(Vector listData)
          Constructs the list's data model from a Vector.
 void setModel(ListModel model)
          Sets the list's data model.
 void setPrototypeCellValue(Object prototypeCellValue)
          Sets the cell size based on an estimate of the cell's width and height.
 void setSelectedIndex(int index)
          Selects a cell by the index.
 void setSelectedIndices(int[] indices)
          Selects the specified cells.
 void setSelectedValue(Object anObject, boolean shouldScroll)
          Selects the specified object.
 void setSelectionBackground(Color selectionBackground)
          Sets the background color for selected cells.
 void setSelectionForeground(Color selectionForeground)
          Sets the foreground color for selected cells.
 void setSelectionInterval(int anchor, int lead)
          Selects the specified interval.
 void updateButtons()
           
 void updateUI()
          Updates the look and feel.
protected  void updateView()
          Initializes and adds a button to the component.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

SELECT_ITEM

protected static final String SELECT_ITEM
See Also:
Constant Field Values

SELECT_ALL

protected static final String SELECT_ALL
See Also:
Constant Field Values

DESELECT_ITEM

protected static final String DESELECT_ITEM
See Also:
Constant Field Values

DESELECT_ALL

protected static final String DESELECT_ALL
See Also:
Constant Field Values

mainList

protected JList mainList

sourceList

protected JList sourceList

selectionList

protected JList selectionList

sourcePane

protected JScrollPane sourcePane

selectionPane

protected JScrollPane selectionPane

selectItemButton

protected JCMultiSelectList.SelectionButton selectItemButton

selectAllButton

protected JCMultiSelectList.SelectionButton selectAllButton

deselectItemButton

protected JCMultiSelectList.SelectionButton deselectItemButton

deselectAllButton

protected JCMultiSelectList.SelectionButton deselectAllButton

buttonPanel

protected JPanel buttonPanel

eventHandler

protected com.klg.jclass.swing.JCMultiSelectList.EventHandler eventHandler

defaultListSize

protected Dimension defaultListSize

lastFontMetrics

protected FontMetrics lastFontMetrics
Constructor Detail

JCMultiSelectList

public JCMultiSelectList(ListModel dataModel)
Constructs a JCMultiSelectList that displays the elements in the specified non-null model. All JCMultiSelectList constructors delegate to this one.

Parameters:
dataModel -

JCMultiSelectList

public JCMultiSelectList(Object[] listData)
Constructs a JCMultiSelectList that displays the elements in the specified array. This constructor just delegates to the ListModel constructor.

Parameters:
listData -

JCMultiSelectList

public JCMultiSelectList(Vector listData)
Constructs a JCMultiSelectList that displays the elements in the specified Vector. This constructor just delegates to the ListModel constructor.

Parameters:
listData -
Since:
JClass 4.0K for Java 2. If you are using the J version, which is based on JDK 1.1, this method's parameter must be a com.sun.java.util.collections.Vector.

JCMultiSelectList

public JCMultiSelectList()
Creates a new JCMultiSelectList component with an empty model.


JCMultiSelectList

public JCMultiSelectList(int hgap)
Creates a new JCMultiSelectList component with an empty model and the specified horizontal gap between components.

Parameters:
hgap -
Method Detail

updateUI

public void updateUI()
Updates the look and feel.

Overrides:
updateUI in class JComponent

getUIClassID

public String getUIClassID()
Returns the name of the UIFactory for this component.

Overrides:
getUIClassID in class JComponent
Returns:
UIFactory name

setAbout

public void setAbout(String s)
Provided for Beans property editors - has no effect.

Parameters:
s -

getAbout

public String getAbout()
Returns vendor information.

Returns:
vendor information

getPrototypeCellValue

public Object getPrototypeCellValue()
Returns the cell size based on an estimate of the cell's width and height.

Returns:
cell size

setPrototypeCellValue

public void setPrototypeCellValue(Object prototypeCellValue)
Sets the cell size based on an estimate of the cell's width and height.

Parameters:
prototypeCellValue -

getFixedCellWidth

public int getFixedCellWidth()
Returns the fixed cell width.

Returns:
fixed cell width

setFixedCellWidth

public void setFixedCellWidth(int width)
Sets the fixed cell width.

Parameters:
width - fixed cell width

getFixedCellHeight

public int getFixedCellHeight()
Returns the fixed cell height.

Returns:
fixed cell height

setFixedCellHeight

public void setFixedCellHeight(int height)
Sets the fixed cell height.

Parameters:
height - fixed cell height

getCellRenderer

public ListCellRenderer getCellRenderer()
Returns the renderer that's used to paint each cell.

Returns:
rendered used to paint each cell

setCellRenderer

public void setCellRenderer(ListCellRenderer cellRenderer)
Sets the renderer that's used to paint each cell.

Parameters:
cellRenderer - rendered used to paint each cell

getSelectionForeground

public Color getSelectionForeground()
Returns the foreground color for selected cells.

Returns:
foreground color for selected cells

setSelectionForeground

public void setSelectionForeground(Color selectionForeground)
Sets the foreground color for selected cells.

Parameters:
selectionForeground - foreground color

getSelectionBackground

public Color getSelectionBackground()
Returns the background color for selected cells.

Returns:
background color for selected cells

setSelectionBackground

public void setSelectionBackground(Color selectionBackground)
Sets the background color for selected cells.

Parameters:
selectionBackground - background color

getModel

public ListModel getModel()
Returns the list's data model.

Returns:
list's data model

setModel

public void setModel(ListModel model)
Sets the list's data model.

Parameters:
model -

setListData

public void setListData(Object[] listData)
Constructs the list's data model from an array of Objects.

Parameters:
listData -

setListData

public void setListData(Vector listData)
Constructs the list's data model from a Vector.

Parameters:
listData -

getSelectionModel

public ListSelectionModel getSelectionModel()
Returns the current selection model.

Returns:
current selection model

addListSelectionListener

public void addListSelectionListener(ListSelectionListener listener)
Adds a listener to the ListSelectionListeners list.

Parameters:
listener -

removeListSelectionListener

public void removeListSelectionListener(ListSelectionListener listener)
Removes a listener from the the ListSelectionListeners list.

Parameters:
listener -

fireSelectionValueChanged

protected void fireSelectionValueChanged(int firstIndex,
                                         int lastIndex,
                                         boolean isAdjusting)
Forwards the given notification event to all registered listeners.

Parameters:
firstIndex -
isAdjusting -
lastIndex -

getSelectionMode

public int getSelectionMode()
Returns the selectionMode property value.

Returns:
selectionMode property value

getAnchorSelectionIndex

public int getAnchorSelectionIndex()
Returns the first index argument from the most recent interval selection.

Returns:
first index argument from the most recent interval selection

getLeadSelectionIndex

public int getLeadSelectionIndex()
Returns the second index argument from the most recent interval selection.

Returns:
second index argument from the most recent interval selection

getMinSelectionIndex

public int getMinSelectionIndex()
Returns the minimal selected cell index.

Returns:
minimal selected cell index

getMaxSelectionIndex

public int getMaxSelectionIndex()
Returns the maximal selected cell index.

Returns:
maximal selected cell index

isSelectedIndex

public boolean isSelectedIndex(int index)
Returns true if the specified index is selected.

Parameters:
index - specified index
Returns:
true if the specified index is selected

isSelectionEmpty

public boolean isSelectionEmpty()
Returns true if nothing is selected.

Returns:
true if nothing is selected

clearSelection

public void clearSelection()
Clears the selection.


setSelectionInterval

public void setSelectionInterval(int anchor,
                                 int lead)
Selects the specified interval.

Parameters:
anchor -
lead -

addSelectionInterval

public void addSelectionInterval(int anchor,
                                 int lead)
Adds the specified interval to the current selection.

Parameters:
anchor -
lead -

removeSelectionInterval

public void removeSelectionInterval(int index0,
                                    int index1)
Removes the specified interval to the current selection.

Parameters:
index0 -
index1 -

getSelectedIndex

public int getSelectedIndex()
Returns the first selected cell index.

Returns:
first selected cell index

setSelectedIndex

public void setSelectedIndex(int index)
Selects a cell by the index.

Parameters:
index -

getSelectedIndices

public int[] getSelectedIndices()
Returns the selected indices array.

Returns:
selected indices array

setSelectedIndices

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

Parameters:
indices -

getSelectedValues

public Object[] getSelectedValues()
Returns an array of the selected cell values.

Returns:
array of the selected cell values

getSelectedValue

public Object getSelectedValue()
Returns the first selected cell value.

Returns:
first selected cell value

setSelectedValue

public void setSelectedValue(Object anObject,
                             boolean shouldScroll)
Selects the specified object.

Parameters:
anObject -
shouldScroll -

paramString

protected String paramString()
Returns a String representation of the object.

Overrides:
paramString in class JComponent
Returns:
String representation of the object

initButton

protected JCMultiSelectList.SelectionButton initButton(JCMultiSelectList.SelectionButton button,
                                                       String toolTipText)
Initializes and adds a button to the component.

Parameters:
button -
toolTipText -
Returns:

init

protected void init()
Initializes the component after it is created.


updateView

protected void updateView()
Initializes and adds a button to the component.


updateButtons

public void updateButtons()

getButtonSize

public static final Dimension getButtonSize()
Returns the nominal size of the component.

Returns:
nominal size of the component

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size of the component.

Overrides:
getPreferredSize in class JComponent
Returns:
preferred size of component

getMinimumSize

public Dimension getMinimumSize()
Returns the minimum size of the component.

Overrides:
getMinimumSize in class JComponent
Returns:
minimum size of component

getMaximumSize

public Dimension getMaximumSize()
Returns the maximum size of the component.

Overrides:
getMaximumSize in class JComponent
Returns:
maximum size of component

paint

public void paint(Graphics g)
Overrides:
paint in class JComponent

getListPreferredWidth

public int getListPreferredWidth()
Returns the preferred width of the list.

Returns:
preferred width of the list

selectItem

protected void selectItem()
Moves the items selected in the left list to the right list.


selectAll

protected void selectAll()
Moves all items from the left list to the right list.


deselectItem

protected void deselectItem()
Moves the items selected in the right list to the left list.


doUpdate

protected void doUpdate(JList list,
                        Object[] values,
                        int[] newIndices)
Move the selected items from one list and also selects the next item in the list.

Parameters:
list - the list which is to be changed
values - the selected values
newIndices - the indeces of the selected items

getIndexFromItem

public int getIndexFromItem(JList list,
                            Object item)
Given an Object, finds its index in the list.

Parameters:
list - the JList to be searched
item - the Object to search for
Returns:
the item's index, or -1 if not found

deselectAll

protected void deselectAll()
Moves all items from the right list to the left list.


setEnabled

public void setEnabled(boolean b)
Enables, disables this component and its subcomponents.

Overrides:
setEnabled in class JComponent
Parameters:
b - boolean: true means enable, false means disable

disableButtons

protected void disableButtons()
Disables all the buttons.


Copyright © 2004 Quest Software Inc..
All rights reserved.