com.tensegrity.gui.swing.control.multiselect
Class MultiSelectPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bycom.tensegrity.gui.swing.control.multiselect.MultiSelectPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable

public class MultiSelectPanel
extends javax.swing.JPanel
implements java.awt.ItemSelectable

A MultiSelectPanel lets you layout selectable items in a grid-alike panel. It can be useful to speed up selection speed for the user, because all items are visible at once.

Version:
$Id: MultiSelectPanel.java,v 1.13 2005/08/25 15:42:28 BurkhardWick Exp $
Author:
Gilles Iachelini
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes 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
MultiSelectPanel(int rows, int columns, MultiSelectItem[] elements)
          Creates a new MultiSelectPanel with the given number of rows and colums and adds the list of elements.
MultiSelectPanel(MultiSelectItem[] elements)
          Method MultiSelectPanel creates a new MultiSelectPanel from the given list of elements.
 
Method Summary
 void addItemListener(java.awt.event.ItemListener listener)
          Creates a new Listener-list if necessary and adds the given listener instance to it.
 void enableMouseOver()
          Method enableMouseOver enables the items to be mouseEnter and mouseExit sensitive.
 MultiSelectItem[] getElements()
          Returns the elements.
 int getSelectedIndex()
          Returns the index of the current selected element, -1 if no element is selected.
 java.lang.Object[] getSelectedObjects()
          Returns an array with the current selection.
 MultiSelectItem getSelection()
          Returns the current selected item.
 void removeItemListener(java.awt.event.ItemListener listener)
          Removes the given listener from the internal ItemListener list.
 void removeNotify()
          This method is overwritten to clear the selection square of the multiselectitems of this panel, if they are mouseOver-sensitive.
 void setElements(MultiSelectItem[] elements)
          Sets the elements of this panel
 void setSelectedIndex(int i)
          Sets element number i from the internal elements list as current selected element and fires a ItemEvent to all listeners.
protected  void setSelection(MultiSelectItem item)
          Clears the current selection and sets the internal selection to item.
 void updateUI()
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI
 
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, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, 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, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, 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
 

Constructor Detail

MultiSelectPanel

public MultiSelectPanel(int rows,
                        int columns,
                        MultiSelectItem[] elements)
Creates a new MultiSelectPanel with the given number of rows and colums and adds the list of elements.

Parameters:
rows - The number of rows for the new MultiSelectPanel.
columns - The number of columns for the new MultiSelectPanel.
elements - the list of elements to be used.

MultiSelectPanel

public MultiSelectPanel(MultiSelectItem[] elements)
Method MultiSelectPanel creates a new MultiSelectPanel from the given list of elements.

Parameters:
elements - the list of elements to create a MultiSelect from.
Method Detail

setSelection

protected void setSelection(MultiSelectItem item)
Clears the current selection and sets the internal selection to item. item will be redrawn. Then a ItemEvent is fired to notify listeners about the selection state change. NOTE: To ease overall handling no DESELECTED event is fired.

Parameters:
item - the MultiSelectItem to select.

setSelectedIndex

public void setSelectedIndex(int i)
Sets element number i from the internal elements list as current selected element and fires a ItemEvent to all listeners.

Parameters:
i - the index within the elements list.

getElements

public MultiSelectItem[] getElements()
Returns the elements.

Returns:
MultiSelectItem[] The array of elements.

addItemListener

public void addItemListener(java.awt.event.ItemListener listener)
Creates a new Listener-list if necessary and adds the given listener instance to it.

Specified by:
addItemListener in interface java.awt.ItemSelectable
Parameters:
listener - the listener to add to the internal list.
See Also:
ItemSelectable.addItemListener(ItemListener)

enableMouseOver

public void enableMouseOver()
Method enableMouseOver enables the items to be mouseEnter and mouseExit sensitive. Optional feature.


removeItemListener

public void removeItemListener(java.awt.event.ItemListener listener)
Removes the given listener from the internal ItemListener list. If the list is empty after the removal, its deleted as well.

Specified by:
removeItemListener in interface java.awt.ItemSelectable
Parameters:
listener - the listener to remove.
See Also:
ItemSelectable.removeItemListener(ItemListener)

getSelectedIndex

public int getSelectedIndex()
Returns the index of the current selected element, -1 if no element is selected.

Returns:
int the index of the selected element or -1.

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Returns an array with the current selection.

Specified by:
getSelectedObjects in interface java.awt.ItemSelectable
Returns:
Object[] the list of elements, which are current selected.
See Also:
ItemSelectable.getSelectedObjects()

getSelection

public MultiSelectItem getSelection()
Returns the current selected item.

Returns:
MultiSelectItem the selected item.

removeNotify

public void removeNotify()
This method is overwritten to clear the selection square of the multiselectitems of this panel, if they are mouseOver-sensitive. The removeNotify is invoked each time the panel is hidden.

See Also:
JComponent.removeNotify()

setElements

public void setElements(MultiSelectItem[] elements)
Sets the elements of this panel

Parameters:
elements - The elements to set

updateUI

public void updateUI()


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.