public abstract class TreeView extends JScrollPane
BeanTreeView
,
ContextTreeView
,
Serialized FormJScrollPane.AccessibleJScrollPane, JScrollPane.ScrollBar
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected JTree |
tree
Main
JTree component. |
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewport
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
TreeView()
Constructor.
|
TreeView(boolean defaultAction,
boolean popupAllowed)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Component comp,
Object constraints) |
void |
addNotify()
Initializes the component and lookup explorer manager.
|
void |
collapseNode(Node n)
Collapses the tree under given node.
|
protected abstract NodeTreeModel |
createModel()
Allows subclasses to provide own model for displaying nodes.
|
void |
expandAll()
Expands all paths.
|
void |
expandNode(Node n)
Expands the node in the tree.
|
int |
getAllowedDragActions()
Actions constants comes from
DnDConstants . |
int |
getAllowedDropActions()
Actions constants comes from
DnDConstants . |
Insets |
getInsets() |
int |
getSelectionMode()
Returns the current selection mode, one of
TreeSelectionModel.SINGLE_TREE_SELECTION ,
TreeSelectionModel.CONTIGUOUS_TREE_SELECTION or
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION . |
boolean |
isDefaultActionEnabled()
Does a double click invoke the default node action?
|
boolean |
isDragSource()
Drag support is enabled by default.
|
boolean |
isDropTarget()
Drop support is enabled by default.
|
boolean |
isExpanded(Node n)
Test whether a node is expanded in the tree or not
|
boolean |
isPopupAllowed()
Is it permitted to display a popup menu?
|
boolean |
isQuickSearchAllowed()
Test whether the quick search feature is enabled or not.
|
boolean |
isRootVisible()
Is the root node of the tree displayed?
|
void |
remove(Component comp) |
void |
removeNotify()
Deinitializes listeners.
|
void |
requestFocus()
Requests focus for the tree component.
|
boolean |
requestFocusInWindow()
Requests focus for the tree component.
|
protected abstract boolean |
selectionAccept(Node[] nodes)
Called when explorer manager is about to change the current selection.
|
protected abstract void |
selectionChanged(Node[] nodes,
ExplorerManager em)
Called to allow subclasses to define the behaviour when a
node(s) are selected in the tree.
|
void |
setAllowedDragActions(int actions)
Sets allowed actions for dragging
|
void |
setAllowedDropActions(int actions)
Sets allowed actions for dropping.
|
void |
setAutoWaitCursor(boolean enable)
Controls automatic setting of wait cursor when node is expanded
|
void |
setDefaultActionAllowed(boolean value)
Enable/disable double click to invoke default action.
|
void |
setDragSource(boolean state)
Enables/disables dragging support.
|
void |
setDropTarget(boolean state)
Enables/disables dropping support.
|
void |
setPopupAllowed(boolean value)
Enable/disable displaying popup menus on tree view items.
|
void |
setQuickSearchAllowed(boolean allowedQuickSearch)
Set whether the quick search feature is enabled or not.
|
void |
setRootVisible(boolean visible)
Set whether or not the root node from
the
TreeModel is visible. |
void |
setSelectionMode(int mode)
Sets the selection model, which must be one of
TreeSelectionModel.SINGLE_TREE_SELECTION,
TreeSelectionModel.CONTIGUOUS_TREE_SELECTION or
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION.
|
void |
setUseSubstringInQuickSearch(boolean useSubstring)
Deprecated.
Since 6.42 does nothing, as the quick search feature uses both substring and prefix
matching. All prefix matches for the typed characters will appear before substring
matches.
|
protected abstract void |
showPath(TreePath path)
Show a given path in the screen.
|
protected abstract void |
showSelection(TreePath[] paths)
Shows selection to reflect the current state of the selection in the explorer.
|
void |
updateUI() |
protected boolean |
useExploredContextMenu()
Specify whether a context menu of the explored context should be used.
|
void |
validate() |
createHorizontalScrollBar, createVerticalScrollBar, createViewport, getAccessibleContext, getColumnHeader, getCorner, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, isWheelScrollingEnabled, paramString, setColumnHeader, setColumnHeaderView, setComponentOrientation, setCorner, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setLayout, setRowHeader, setRowHeaderView, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportBorder, setViewportView, setWheelScrollingEnabled
addAncestorListener, 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, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, 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
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, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validateTree
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, 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, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected transient JTree tree
JTree
component.public TreeView()
public TreeView(boolean defaultAction, boolean popupAllowed)
defaultAction
- should double click on a node open its default action?popupAllowed
- should right-click open popup?public void updateUI()
updateUI
in class JScrollPane
public boolean isPopupAllowed()
true
if sopublic void setPopupAllowed(boolean value)
value
- true
to enablepublic boolean isDefaultActionEnabled()
true
if sopublic void requestFocus()
requestFocus
in class JComponent
public boolean requestFocusInWindow()
requestFocusInWindow
in class JComponent
public void setDefaultActionAllowed(boolean value)
value
- true
to enablepublic boolean isRootVisible()
true
if sopublic void setRootVisible(boolean visible)
TreeModel
is visible.visible
- true
if it is to be displayedpublic boolean isQuickSearchAllowed()
public void setQuickSearchAllowed(boolean allowedQuickSearch)
allowedQuickSearch
- true
if quick search shall be enabled@Deprecated public void setUseSubstringInQuickSearch(boolean useSubstring)
useSubstring
- true
if substring search is used in quick searchpublic boolean isDragSource()
public void setDragSource(boolean state)
state
- true enables dragging support, false disables it.public boolean isDropTarget()
public void setDropTarget(boolean state)
state
- true means drops into view are allowed,
false forbids any drops into this view.public int getAllowedDragActions()
DnDConstants
.
All actions (copy, move, link) are allowed by default.public void setAllowedDragActions(int actions)
actions
- new drag actions, using DnDConstants
public int getAllowedDropActions()
DnDConstants
.
All actions are allowed by default.public void setAllowedDropActions(int actions)
actions
- new allowed drop actions, using DnDConstants
public void collapseNode(Node n)
n
- node to collapsepublic void expandNode(Node n)
EventQueue.invokeLater(java.lang.Runnable)
and really expands the noden
- nodeIllegalArgumentException
- if the node is nullpublic boolean isExpanded(Node n)
n
- the node to testpublic void expandAll()
public void addNotify()
addNotify
in class JComponent
public void removeNotify()
removeNotify
in class JComponent
protected abstract NodeTreeModel createModel()
protected abstract void selectionChanged(Node[] nodes, ExplorerManager em) throws PropertyVetoException
nodes
- the selected nodesem
- explorer manager to work on (change nodes to it)PropertyVetoException
- if the change cannot be done by the explorer
(the exception is silently consumed)protected abstract boolean selectionAccept(Node[] nodes)
nodes
- the nodes to selectprotected abstract void showPath(TreePath path)
TreeView
if the path should be expanded or just made visible.path
- the pathprotected abstract void showSelection(TreePath[] paths)
paths
- array of paths that should be selectedprotected boolean useExploredContextMenu()
true
if so; false
in the default implementationpublic void setSelectionMode(int mode)
This may change the selection if the current selection is not valid
for the new mode. For example, if three TreePaths are
selected when the mode is changed to TreeSelectionModel.SINGLE_TREE_SELECTION
,
only one TreePath will remain selected. It is up to the particular
implementation to decide what TreePath remains selected.
Note: TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION is set as default.
mode
- selection modepublic int getSelectionMode()
TreeSelectionModel.SINGLE_TREE_SELECTION
,
TreeSelectionModel.CONTIGUOUS_TREE_SELECTION
or
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION
.public void setAutoWaitCursor(boolean enable)
enable
- true if wait cursor should be shown automaticallypublic Insets getInsets()
getInsets
in class JComponent