edu.princeton.swing
Class PList

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JList
                  extended by edu.princeton.swing.PList
All Implemented Interfaces:
ClipboardTarget, ImageObserver, MenuContainer, Serializable, Accessible, Scrollable
Direct Known Subclasses:
PWrappedList

public class PList
extends JList
implements ClipboardTarget

PList extends JList to provide ClipboardTarget support.

See Also:
Serialized Form

Nested Class Summary
protected  class PList.Listener
          The Listener listenes to the selection model of this list to capture PropertyChangeEvents.
protected static class PList.PListCellRenderer
          PListCellRenderer is a subclass of DefaultListCellRenderer which will correctly render the border specified by the PList.
 
Nested classes/interfaces inherited from class javax.swing.JList
JList.AccessibleJList, JList.DropLocation
 
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
protected  Border focusedCellBorder
           
 
Fields inherited from class javax.swing.JList
HORIZONTAL_WRAP, VERTICAL, VERTICAL_WRAP
 
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
PList()
          Constructs a new PList.
PList(ListModel dataModel)
          Constructs a new PList.
PList(Object[] listData)
          Constructs a new PList.
PList(Vector listData)
          Constructs a new PList.
 
Method Summary
 void addActionListener(ActionListener listener)
          Adds a listener to monitor action events (enter key events) on the PTextField.
 boolean canCopy()
          Returns wheter or not the copy operation can be performed on this ClipboardTarget.
 boolean canCut()
          Returns wheter or not the cut operation can be performed on this ClipboardTarget.
 boolean canPaste()
          Returns wheter or not the paste operation can be performed on this ClipboardTarget.
 boolean canSelectAll()
          Returns wheter or not the selectAll operation can be performed on this ClipboardTarget.
 void copy()
          Copies the selection to the clipboard.
protected  ListSelectionModel createSelectionModel()
          Override the createSelectionModel function to use our own selectionModel function which actually monitors the selection mode.
 void cut()
          Copies the selection to the clipboard and remove it from the object.
 String getActionCommand()
          Returns the action command associated with the enter key being pressed.
 Border getFocusedCellBorder()
          Return the border that should be rendered for a focused cell.
 JPopupMenu getPopupMenu()
          Gets the popup menu for this component.
 Border getUnfocusedCellBorder()
          Return the border that should be rendered for an unfocused cell.
 void paste()
          Inserts the contents of the clipbaord into the object.
protected  void processFocusEvent(FocusEvent e)
          Intercept FocusEvents to notify the ClipboardTargetManager of the event.
protected  void processMouseEvent(MouseEvent e)
          Intercept MouseEvents to activate the popupMenu at the right time.
 void removeActionListener(ActionListener listener)
          Removes a listener from this component.
 void selectAll()
          Selects everything in the object.
 void setActionCommand(String actionCommand)
          Sets the action command associated with the enter key being pressed.
 void setEnabled(boolean enabled)
          Override the setEnabled() method to intercept any changes concerning the enabled status of the component.
 void setPopupMenu(JPopupMenu popupMenu)
          Sets the popup menu for this component.
 void setSelectionBackground(Color selectionBackground)
          Override the setSelectionBackground() method to intercept any changes concerning the background color of the selection.
 void setSelectionModel(ListSelectionModel selectionModel)
          Override the setSelectionModel method to reject any attempt to change the selection model to a model which does not implement PropertiedListSelectionModel.
 
Methods inherited from class javax.swing.JList
addListSelectionListener, addSelectionInterval, clearSelection, ensureIndexIsVisible, fireSelectionValueChanged, getAccessibleContext, getAnchorSelectionIndex, getCellBounds, getCellRenderer, getDragEnabled, getDropLocation, getDropMode, getFirstVisibleIndex, getFixedCellHeight, getFixedCellWidth, getLastVisibleIndex, getLayoutOrientation, getLeadSelectionIndex, getListSelectionListeners, getMaxSelectionIndex, getMinSelectionIndex, getModel, getNextMatch, getPreferredScrollableViewportSize, getPrototypeCellValue, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedIndex, getSelectedIndices, getSelectedValue, getSelectedValues, getSelectionBackground, getSelectionForeground, getSelectionMode, getSelectionModel, getToolTipText, getUI, getUIClassID, getValueIsAdjusting, getVisibleRowCount, indexToLocation, isSelectedIndex, isSelectionEmpty, locationToIndex, paramString, removeListSelectionListener, removeSelectionInterval, setCellRenderer, setDragEnabled, setDropMode, setFixedCellHeight, setFixedCellWidth, setLayoutOrientation, setListData, setListData, setModel, setPrototypeCellValue, setSelectedIndex, setSelectedIndices, setSelectedValue, setSelectionForeground, setSelectionInterval, setSelectionMode, setUI, setValueIsAdjusting, setVisibleRowCount, updateUI
 
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, 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, 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, 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, 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

focusedCellBorder

protected Border focusedCellBorder
Constructor Detail

PList

public PList()
Constructs a new PList.


PList

public PList(ListModel dataModel)
Constructs a new PList.


PList

public PList(Object[] listData)
Constructs a new PList.


PList

public PList(Vector listData)
Constructs a new PList.

Method Detail

addActionListener

public void addActionListener(ActionListener listener)
Adds a listener to monitor action events (enter key events) on the PTextField.

Parameters:
listener - The listener to add to this document. A null value will cause a NullPointerException.

removeActionListener

public void removeActionListener(ActionListener listener)
Removes a listener from this component. Nothing will happen if no match was found.

Parameters:
listener - The listener to remove from this document. A null value will cause a NullPointerException.

getActionCommand

public String getActionCommand()
Returns the action command associated with the enter key being pressed. A null value indicates thatthe text of the text field at the time of the event will be used. return The action command to be associated with the enter key.


setActionCommand

public void setActionCommand(String actionCommand)
Sets the action command associated with the enter key being pressed.

Parameters:
actionCommand - The action command to be associated with the enter key. If null is passed, the text of the text field at the time of the event will be used.

canCut

public boolean canCut()
Returns wheter or not the cut operation can be performed on this ClipboardTarget.

Specified by:
canCut in interface ClipboardTarget
Returns:
True iff a call to cut() should be permitted.

cut

public void cut()
Copies the selection to the clipboard and remove it from the object. The clipboard should not be modified if nothing is selected.

Specified by:
cut in interface ClipboardTarget

canCopy

public boolean canCopy()
Returns wheter or not the copy operation can be performed on this ClipboardTarget.

Specified by:
canCopy in interface ClipboardTarget
Returns:
True iff a call to copy() should be permitted.

copy

public void copy()
Copies the selection to the clipboard. The clipboard should not be modified if nothing is selected.

Specified by:
copy in interface ClipboardTarget

canPaste

public boolean canPaste()
Returns wheter or not the paste operation can be performed on this ClipboardTarget.

Specified by:
canPaste in interface ClipboardTarget
Returns:
True iff a call to paste() should be permitted.

paste

public void paste()
Inserts the contents of the clipbaord into the object. Optional: Before inserting the contents of the clipboard, remove the current selection from the object.

Specified by:
paste in interface ClipboardTarget

canSelectAll

public boolean canSelectAll()
Returns wheter or not the selectAll operation can be performed on this ClipboardTarget.

Specified by:
canSelectAll in interface ClipboardTarget
Returns:
True iff a call to selectAll() should be permitted.

selectAll

public void selectAll()
Selects everything in the object.

Specified by:
selectAll in interface ClipboardTarget

processFocusEvent

protected void processFocusEvent(FocusEvent e)
Intercept FocusEvents to notify the ClipboardTargetManager of the event.

Overrides:
processFocusEvent in class Component

processMouseEvent

protected void processMouseEvent(MouseEvent e)
Intercept MouseEvents to activate the popupMenu at the right time.

Overrides:
processMouseEvent in class JComponent

setSelectionBackground

public void setSelectionBackground(Color selectionBackground)
Override the setSelectionBackground() method to intercept any changes concerning the background color of the selection.

Overrides:
setSelectionBackground in class JList

getFocusedCellBorder

public Border getFocusedCellBorder()
Return the border that should be rendered for a focused cell.

Returns:
The border that should be rendered for a focused cell.

getUnfocusedCellBorder

public Border getUnfocusedCellBorder()
Return the border that should be rendered for an unfocused cell.

Returns:
The border that should be rendered for an unfocused cell.

setEnabled

public void setEnabled(boolean enabled)
Override the setEnabled() method to intercept any changes concerning the enabled status of the component.

Overrides:
setEnabled in class JComponent

setSelectionModel

public void setSelectionModel(ListSelectionModel selectionModel)
Override the setSelectionModel method to reject any attempt to change the selection model to a model which does not implement PropertiedListSelectionModel.

Overrides:
setSelectionModel in class JList

createSelectionModel

protected ListSelectionModel createSelectionModel()
Override the createSelectionModel function to use our own selectionModel function which actually monitors the selection mode.

Overrides:
createSelectionModel in class JList

getPopupMenu

public JPopupMenu getPopupMenu()
Gets the popup menu for this component.

Returns:
The popup menu for the component. Null is returned if this component does not have a popup menu.

setPopupMenu

public void setPopupMenu(JPopupMenu popupMenu)
Sets the popup menu for this component.

Parameters:
popupMenu - The popup menu for the component. A null value indicates that this component should not have a popup menu.