public class JPropertyTreePanel extends JSplitPane
There are three ways to add property nodes to the tree :
addPropertyListNode(DefaultMutableTreeNode, String, Icon, PropertyEditor)
or
addPropertyListNode(DefaultMutableTreeNode, String, PropertyEditor)
methods.
PropertyEditor
is the editor associated with the nodeaddEmptyNode(DefaultMutableTreeNode, String, Icon)
or
addEmptyNode(DefaultMutableTreeNode, String)
methods.
addNode(DefaultMutableTreeNode, DefaultMutableTreeNode, Icon)
or
addNode(DefaultMutableTreeNode, DefaultMutableTreeNode)
methods.
PropertyEditor
s associated with the nodes,PropertyEditor
.
Example: To create a new JPropertyTreePanel
:
PropertyEditor
s and set them visiblePropertyEditor p1 = new PropertyEditor(); JTextField tf = new JTextField("1"); p1.addProperty(tf,"1","prop 1"); p1.setVisible(true); PropertyEditor p2 = new PropertyEditor(); JTextField tf2 = new JTextField("2"); p2.addProperty(tf2,"2","prop 2"); p2.setVisible(true);
JPropertyTreePanel
JPropertyTreePanel panel = new JPropertyTreePanel();
panel.addPropertyListNode(panel.getRootNode(), "node 1", p1); DefaultMutableTreeNode node = panel.addEmptyNode(panel.getRootNode(), "sub-node"); panel.addPropertyListNode(node, "node 2", p2);
Modifier and Type | Class and Description |
---|---|
class |
JPropertyTreePanel.PropertyTreeRenderer
This internal class is responsble for nodes rendering.
|
JSplitPane.AccessibleJSplitPane
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected DefaultTreeModel |
model |
protected Map<DefaultMutableTreeNode,Object> |
props |
protected JPropertyTreePanel.PropertyTreeRenderer |
renderer |
protected JSplitPane |
split |
protected JTree |
tree |
BOTTOM, CONTINUOUS_LAYOUT_PROPERTY, continuousLayout, DIVIDER, DIVIDER_LOCATION_PROPERTY, DIVIDER_SIZE_PROPERTY, dividerSize, HORIZONTAL_SPLIT, LAST_DIVIDER_LOCATION_PROPERTY, lastDividerLocation, LEFT, leftComponent, ONE_TOUCH_EXPANDABLE_PROPERTY, oneTouchExpandable, orientation, ORIENTATION_PROPERTY, RESIZE_WEIGHT_PROPERTY, RIGHT, rightComponent, TOP, VERTICAL_SPLIT
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
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
JPropertyTreePanel()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
DefaultMutableTreeNode |
addEmptyNode(DefaultMutableTreeNode parentnode,
String listname)
Add an empty node to the tree, with no icon.
|
DefaultMutableTreeNode |
addEmptyNode(DefaultMutableTreeNode parentnode,
String listname,
Icon icon)
Add an empty node to the tree, and associate this node with an icon.
|
DefaultMutableTreeNode |
addNode(DefaultMutableTreeNode parentnode,
DefaultMutableTreeNode childNode)
Add a custom node to the tree, with no icon.
|
DefaultMutableTreeNode |
addNode(DefaultMutableTreeNode parentnode,
DefaultMutableTreeNode childNode,
Icon icon)
Add a custom node to the tree, and associate it with an icon.
|
DefaultMutableTreeNode |
addPropertyListNode(DefaultMutableTreeNode parentnode,
String listname,
Icon icon,
PropertyEditor editor)
Add a node to the tree, and associate this node with a PropertyEditor, and an icon.
|
DefaultMutableTreeNode |
addPropertyListNode(DefaultMutableTreeNode parentnode,
String listname,
PropertyEditor editor)
Add a node to the tree, with an associated PropertyEditor, but no icon.
|
protected void |
changePropertyView(DefaultMutableTreeNode node)
This method is used internally to manage node selections in the tree :
|
void |
collapseAll() |
void |
expandAll() |
DefaultMutableTreeNode |
getRootNode()
Return the root node of the tree.
|
JSplitPane |
getSplitPane()
Return the internal JSplitPane.
|
JTree |
getTree() |
TreeModel |
getTreeModel()
Return the internal TreeModel.
|
addImpl, getAccessibleContext, getBottomComponent, getDividerLocation, getDividerSize, getLastDividerLocation, getLeftComponent, getMaximumDividerLocation, getMinimumDividerLocation, getOrientation, getResizeWeight, getRightComponent, getTopComponent, getUI, getUIClassID, isContinuousLayout, isOneTouchExpandable, isValidateRoot, paintChildren, paramString, remove, remove, removeAll, resetToPreferredSizes, setBottomComponent, setContinuousLayout, setDividerLocation, setDividerLocation, setDividerSize, setLastDividerLocation, setLeftComponent, setOneTouchExpandable, setOrientation, setResizeWeight, setRightComponent, setTopComponent, setUI, updateUI
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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintComponent, paintImmediately, paintImmediately, 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
add, add, add, add, add, addContainerListener, 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, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, 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, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected JTree tree
protected DefaultTreeModel model
protected JPropertyTreePanel.PropertyTreeRenderer renderer
protected JSplitPane split
protected Map<DefaultMutableTreeNode,Object> props
public DefaultMutableTreeNode addEmptyNode(DefaultMutableTreeNode parentnode, String listname, Icon icon)
parentnode
- the parent node of the newly created nodelistname
- the name of the nodeicon
- the optional icon to associate with the node (or null if there is no icon)public DefaultMutableTreeNode addEmptyNode(DefaultMutableTreeNode parentnode, String listname)
parentnode
- the parent node of the newly created nodelistname
- the name of the nodepublic DefaultMutableTreeNode addNode(DefaultMutableTreeNode parentnode, DefaultMutableTreeNode childNode)
parentnode
- the parent node of the newly created nodechildNode
- the child node of the newly created nodeaddNode(DefaultMutableTreeNode, DefaultMutableTreeNode, Icon)
public DefaultMutableTreeNode addNode(DefaultMutableTreeNode parentnode, DefaultMutableTreeNode childNode, Icon icon)
This Node can contain other nodes, and each of these nodes can be associated with
a PropertyEditor
userObject. This allows to add easily a whole property tree
structure to the node.
For example, the following code add two nodes associated with PropertyEditor
s :
PropertyEditor
s :PropertyEditor p1 = new PropertyEditor(); JTextField tf = new JTextField("1"); p1.addProperty(tf,"1","prop 1"); p1.setVisible(true); PropertyEditor p2 = new PropertyEditor(); JTextField tf2 = new JTextField("2"); p2.addProperty(tf,"2","prop 2"); p2.setVisible(true);
DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("Node 1"); node1.setUserObject(p1); DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("Node 2"); node2.setUserObject(p2);
JPropertyTreePanel
JPropertyTreePanel panel = new JPropertyTreePanel(); panel.addEmptyNode(panel.getRootNode(), node1, null); panel.addEmptyNode(panel.getRootNode(), node2, null);
parentnode
- the parent node of the newly created nodechildNode
- the child node of the newly created nodeicon
- the optional icon to associate with the node (or null if there is no icon)public DefaultMutableTreeNode addPropertyListNode(DefaultMutableTreeNode parentnode, String listname, Icon icon, PropertyEditor editor)
parentnode
- the parent node of the newly created nodelistname
- the name of the nodeicon
- the optional icon to associate with the node (or null if there is no icon)editor
- the PropertyEditor
associated with the nodepublic DefaultMutableTreeNode addPropertyListNode(DefaultMutableTreeNode parentnode, String listname, PropertyEditor editor)
parentnode
- the parent node of the newly created nodelistname
- the name of the nodeeditor
- the PropertyEditor
associated with the nodepublic DefaultMutableTreeNode getRootNode()
protected void changePropertyView(DefaultMutableTreeNode node)
node
- the nodepublic JTree getTree()
public JSplitPane getSplitPane()
public TreeModel getTreeModel()
public void expandAll()
public void collapseAll()