|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.Box edu.sdsc.inca.IncatList
public class IncatList
A convenience class that combines a scrollable JList and its Model. It allows listening for focus and list selection events via an ActionListener instead of a Focus/ListSelectionListener. Action commands generated by an IncatList are: DoubleClick -- user has double-clicked a selection FocusLost -- the list has lost keyboard focus FocusGained -- the list has gained keyboard focus SingleClick -- user has single-clicked a selection XXX -- user has clicked the associated button labeled with XXX Class instances prefix each of these commands with a client-supplied prefix to allow listeners to distinguish between actions from multiple IncatLists.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.Box |
---|
javax.swing.Box.AccessibleBox, javax.swing.Box.Filler |
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 | |
---|---|
protected java.lang.String |
commandPrefix
|
protected static java.lang.String |
lastFind
|
protected javax.swing.JList |
list
|
protected java.awt.event.ActionListener |
listener
|
protected javax.swing.DefaultListModel |
model
|
Fields inherited from class javax.swing.Box |
---|
accessibleContext |
Fields inherited from class javax.swing.JComponent |
---|
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 | |
---|---|
IncatList(java.lang.String title,
java.lang.String prefix,
java.lang.String buttons,
java.awt.event.ActionListener listener)
Constructs an IncatList. |
Method Summary | |
---|---|
void |
addElement(java.lang.Object o)
Appends an element to the end of the list. |
protected static void |
findListElement(boolean prompt)
Searches for an element in a list. |
int |
findMatchingElement(java.lang.String s)
Returns the index of the element that matches a specific string; returns -1 if no element matches. |
void |
focusGained(java.awt.event.FocusEvent e)
Forwards focus events to this list's listener. |
void |
focusLost(java.awt.event.FocusEvent e)
Forwards focus events to this list's listener. |
java.awt.event.ActionListener |
getActionListener()
Returns the listener notified when the user selects an element. |
java.lang.String |
getCommandPrefix()
Returns the string prepended to action commands generated by this list. |
java.lang.Object |
getElementAt(int index)
Return the element at a specified index. |
int |
getLength()
Returns the length of the list. |
java.lang.Object |
getSelectedElement()
Returns the first selected element; returns null if none. |
int |
getSelectedIndex()
Returns the first selected index; returns -1 if none. |
void |
insertElementAt(java.lang.Object o,
int index)
Adds an element at a specified position in the list. |
static javax.swing.JLabel |
listElementLabel(javax.swing.JList list,
java.lang.Object element,
boolean isSelected)
Creates and returns a JLabel to represent a list element. |
void |
mouseClicked(java.awt.event.MouseEvent e)
Forwards selection events to the list's listener. |
void |
mouseEntered(java.awt.event.MouseEvent e)
|
void |
mouseExited(java.awt.event.MouseEvent e)
|
void |
mousePressed(java.awt.event.MouseEvent e)
|
void |
mouseReleased(java.awt.event.MouseEvent e)
|
void |
removeAllElements()
Removes all elements from the list. |
void |
removeElementAt(int index)
Removes the element, if any, at a specified index. |
boolean |
selectMatchingElement(java.lang.String s)
Selects the element that matches a specified string. |
void |
setActionListener(java.awt.event.ActionListener listener)
Sets the listener notified when the user selects an element. |
void |
setCellRenderer(javax.swing.ListCellRenderer lcr)
Sets the class that determines the presentation of list elements. |
void |
setCommandPrefix(java.lang.String prefix)
Sets the string prepended to action commands generated by this list. |
void |
setElementAt(java.lang.Object o,
int index)
Replaces an element at a specified position in the list. |
void |
setElements(java.lang.Object[] elements)
Removes all existing elements from the list and adds a specified set. |
boolean |
setSelectedElement(java.lang.Object o)
Selects a specified element. |
void |
setSelectedIndex(int index)
Selects the element, if any, at the specified index. |
void |
sort()
Rearranges the list to display the elements in increasing alpha order. |
java.lang.Object[] |
toArray()
Returns an array of the elements in this list. |
java.lang.Object[] |
toArray(java.lang.Object[] a)
Returns an array of the element in this list. |
void |
valueChanged(javax.swing.event.ListSelectionEvent e)
Forwards list selections to the list's listener. |
Methods inherited from class javax.swing.Box |
---|
createGlue, createHorizontalBox, createHorizontalGlue, createHorizontalStrut, createRigidArea, createVerticalBox, createVerticalGlue, createVerticalStrut, getAccessibleContext, setLayout |
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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, 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, updateUI |
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, 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 |
---|
protected static java.lang.String lastFind
protected java.lang.String commandPrefix
protected javax.swing.JList list
protected java.awt.event.ActionListener listener
protected javax.swing.DefaultListModel model
Constructor Detail |
---|
public IncatList(java.lang.String title, java.lang.String prefix, java.lang.String buttons, java.awt.event.ActionListener listener)
title
- title for this list, optionalprefix
- text prepended to action commands generated by this list,
optionalbuttons
- comma-delimited list of labels for buttons to attach to
this list, optionallistener
- listener to notify when the user acts on the list/buttons,
optionalMethod Detail |
---|
public void addElement(java.lang.Object o)
o
- the element to appendpublic int findMatchingElement(java.lang.String s)
s
- the string to match
public java.awt.event.ActionListener getActionListener()
public java.lang.String getCommandPrefix()
public java.lang.Object getElementAt(int index)
index
- the requested index
public int getLength()
public java.lang.Object getSelectedElement()
public int getSelectedIndex()
public void insertElementAt(java.lang.Object o, int index)
o
- the object to insertindex
- the position to insert the objectpublic void removeAllElements()
public void removeElementAt(int index)
index
- the requested indexpublic boolean selectMatchingElement(java.lang.String s)
s
- the value to match
public void setActionListener(java.awt.event.ActionListener listener)
listener
- the listenerpublic void setCellRenderer(javax.swing.ListCellRenderer lcr)
the
- cell renderer for this listpublic void setCommandPrefix(java.lang.String prefix)
prefix
- the command prefixpublic void setElementAt(java.lang.Object o, int index)
o
- the object to insertindex
- the position to replace with the objectpublic void setElements(java.lang.Object[] elements)
elements
- the set of elements to addpublic boolean setSelectedElement(java.lang.Object o)
o
- the element to select
public void setSelectedIndex(int index)
index
- the requested indexpublic void sort()
public java.lang.Object[] toArray()
public java.lang.Object[] toArray(java.lang.Object[] a)
a
- the array to contain the elements--the length must match the
number of elements in the IncatList, optional
public void focusGained(java.awt.event.FocusEvent e)
focusGained
in interface java.awt.event.FocusListener
public void focusLost(java.awt.event.FocusEvent e)
focusLost
in interface java.awt.event.FocusListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void valueChanged(javax.swing.event.ListSelectionEvent e)
valueChanged
in interface javax.swing.event.ListSelectionListener
protected static void findListElement(boolean prompt)
prompt
- ask the user to enter a search text; if false, reuse the
most recent textpublic static javax.swing.JLabel listElementLabel(javax.swing.JList list, java.lang.Object element, boolean isSelected)
list
- the list that contains the elementelement
- the element to representisSelected
- indicates whether the element is currently selected
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |