edu.princeton.swing
Class PTree
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTree
edu.princeton.swing.PTree
- All Implemented Interfaces:
- ClipboardTarget, ImageObserver, MenuContainer, Serializable, Accessible, Scrollable
public class PTree
- extends JTree
- implements ClipboardTarget
PTree extends JTree to provide ClipboardTarget support.
- See Also:
- Serialized Form
Nested Class Summary |
protected class |
PTree.Listener
The Listener listenes to the selection model of this list to capture PropertyChangeEvents. |
Fields inherited from class javax.swing.JTree |
ANCHOR_SELECTION_PATH_PROPERTY, CELL_EDITOR_PROPERTY, CELL_RENDERER_PROPERTY, cellEditor, cellRenderer, editable, EDITABLE_PROPERTY, EXPANDS_SELECTED_PATHS_PROPERTY, INVOKES_STOP_CELL_EDITING_PROPERTY, invokesStopCellEditing, LARGE_MODEL_PROPERTY, largeModel, LEAD_SELECTION_PATH_PROPERTY, ROOT_VISIBLE_PROPERTY, rootVisible, ROW_HEIGHT_PROPERTY, rowHeight, SCROLLS_ON_EXPAND_PROPERTY, scrollsOnExpand, SELECTION_MODEL_PROPERTY, selectionModel, selectionRedirector, SHOWS_ROOT_HANDLES_PROPERTY, showsRootHandles, TOGGLE_CLICK_COUNT_PROPERTY, toggleClickCount, TREE_MODEL_PROPERTY, treeModel, treeModelListener, VISIBLE_ROW_COUNT_PROPERTY, visibleRowCount |
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. |
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. |
JPopupMenu |
getPopupMenu()
Gets the popup menu for this component. |
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 |
setSelectionModel(TreeSelectionModel selectionModel)
Override the setSelectionModel method to keep our listener on the correct model. |
Methods inherited from class javax.swing.JTree |
addSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, cancelEditing, clearSelection, clearToggledPaths, collapsePath, collapseRow, convertValueToText, createTreeModel, createTreeModelListener, expandPath, expandRow, fireTreeCollapsed, fireTreeExpanded, fireTreeWillCollapse, fireTreeWillExpand, fireValueChanged, getAccessibleContext, getAnchorSelectionPath, getCellEditor, getCellRenderer, getClosestPathForLocation, getClosestRowForLocation, getDefaultTreeModel, getDescendantToggledPaths, getDragEnabled, getDropLocation, getDropMode, getEditingPath, getExpandedDescendants, getExpandsSelectedPaths, getInvokesStopCellEditing, getLastSelectedPathComponent, getLeadSelectionPath, getLeadSelectionRow, getMaxSelectionRow, getMinSelectionRow, getModel, getNextMatch, getPathBetweenRows, getPathBounds, getPathForLocation, getPathForRow, getPreferredScrollableViewportSize, getRowBounds, getRowCount, getRowForLocation, getRowForPath, getRowHeight, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollsOnExpand, getSelectionCount, getSelectionModel, getSelectionPath, getSelectionPaths, getSelectionRows, getShowsRootHandles, getToggleClickCount, getToolTipText, getTreeExpansionListeners, getTreeSelectionListeners, getTreeWillExpandListeners, getUI, getUIClassID, getVisibleRowCount, hasBeenExpanded, isCollapsed, isCollapsed, isEditable, isEditing, isExpanded, isExpanded, isFixedRowHeight, isLargeModel, isPathEditable, isPathSelected, isRootVisible, isRowSelected, isSelectionEmpty, isVisible, makeVisible, paramString, removeDescendantSelectedPaths, removeDescendantToggledPaths, removeSelectionInterval, removeSelectionPath, removeSelectionPaths, removeSelectionRow, removeSelectionRows, removeTreeExpansionListener, removeTreeSelectionListener, removeTreeWillExpandListener, scrollPathToVisible, scrollRowToVisible, setAnchorSelectionPath, setCellEditor, setCellRenderer, setDragEnabled, setDropMode, setEditable, setExpandedState, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, setModel, setRootVisible, setRowHeight, setScrollsOnExpand, setSelectionInterval, setSelectionPath, setSelectionPaths, setSelectionRow, setSelectionRows, setShowsRootHandles, setToggleClickCount, setUI, setVisibleRowCount, startEditingAtPath, stopEditing, treeDidChange, 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 |
PTree
public PTree()
- Constructs a new PTree.
PTree
public PTree(Hashtable value)
- Constructs a new PTree.
PTree
public PTree(Object[] value)
- Constructs a new PTree.
PTree
public PTree(TreeModel newModel)
- Constructs a new PTree.
PTree
public PTree(TreeNode root)
- Constructs a new PTree.
PTree
public PTree(TreeNode root,
boolean asksAllowsChildren)
- Constructs a new PTree.
PTree
public PTree(Vector value)
- Constructs a new PTree.
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
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(TreeSelectionModel selectionModel)
- Override the setSelectionModel method to keep our listener on the correct model.
- Overrides:
setSelectionModel
in class JTree
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.