public abstract class MasterDetailTreeNode extends Object implements TreeNode, Serializable
JTree with exactly one TreeModel.
The root node stores these. Through a node's parents one gets to the root, and thus these.
fetchChildren, called once.
parent==null then this node is root. In which case it stores table model and tree.
All nodes have getTableModel etc methods, they just call parent.getTableModel until
root is found.
deleteNode0, redraw, getTreePath etc.
Node.CellRenderer, allowing icon,text,extra-text to be displayed
newPopupMenu
Tree t = new Tree(); // from NetBeans UI designer
MyRootNode n = new MyNode(null); // extends MasterDetailTreeNode, parent==null
n.installIntoTreeAsRootNode(t);
| Modifier and Type | Class and Description |
|---|---|
protected class |
MasterDetailTreeNode.CellRenderer |
protected class |
MasterDetailTreeNode.TreeListener |
| Modifier and Type | Field and Description |
|---|---|
protected MasterDetailTreeNode |
candidateDropTarget
if root, candidate drop target, otherwise null
|
protected MasterDetailTreeNode[] |
children
Contains children if loaded, or null meaning not yet loaded
|
protected MasterDetailTreeNode |
parent
Must always be set, or null if root node
|
protected JTree |
tree
if root, assigned to a tree, this is a value, otherwise null
|
protected DefaultTreeModel |
treeModel
if root, assigned to a tree, this is a value, otherwise null
|
| Modifier | Constructor and Description |
|---|---|
protected |
MasterDetailTreeNode(MasterDetailTreeNode parent) |
| Modifier and Type | Method and Description |
|---|---|
Enumeration<MasterDetailTreeNode> |
children() |
protected void |
deleteNode0(MasterDetailTreeNode node)
Deletes a node, which must be a member of this's children.
|
void |
expandAllChildren() |
protected int |
expandJTreeNode(JTree tree,
TreeModel model,
MasterDetailTreeNode node,
int row) |
protected abstract MasterDetailTreeNode[] |
fetchChildren()
Create and return children.
|
int |
getAcceptableDropActions()
Returns a bitmask of acceptable actions such as
DnDConstants.ACTION_COPY. |
DataFlavor[] |
getAcceptableDropFlavors()
Returns array of Flavors which can be accepted, in the case a drag & drop
attempts to drop on this node.
|
TreeNode |
getChildAt(int param) |
int |
getChildCount() |
MasterDetailTreeNode[] |
getChildren() |
String |
getExtraText()
Returns the text which is in color at the end of the name.
|
Color |
getExtraTextColor()
Returns the color which should be used for the extra text.
|
int |
getIndex(TreeNode treeNode) |
protected String |
getLeafNameForNodeKey(String key) |
TreeNode |
getParent() |
protected MasterDetailTreeNode |
getRootNode() |
MasterDetailTreeNode |
getSelectedNode()
Can be called anywhere on the tree.
|
protected JTree |
getTree() |
abstract ImageIcon |
getTreeIcon()
Returns an ImageIcon which represents this icon, to be displayed to the
left of it in the tree-view
|
protected DefaultTreeModel |
getTreeModel() |
abstract String |
getTreeText()
Returns the text which can be used to display this icon in the
tree-view
|
protected void |
informTreeModelThatNodeHasRadicallyChanged() |
void |
installIntoTreeAsRootNode(JTree tree,
JPanel detailPanelContainer,
JPanel defaultDetailPanel)
Sets
Node.treeModel and makes this the first node
of it. |
boolean |
isLeaf() |
abstract JPanel |
newDetailJPanel()
Create and return a Panel which can be displayed on the right hand
side of the window, when this node is selected.
|
JPopupMenu |
newPopupMenu()
Create and return a JPopupMenu which can be displayed when the user
right-clicks on this node, or null for no pop-up menu
|
TreePath |
newTreePath() |
void |
redraw() |
void |
select() |
void |
setParent(MasterDetailTreeNode n) |
void |
transferrableHasBeenDropped(DropTargetDropEvent e)
When a
Transferrable is dropped on this node, this method
is called. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAllowsChildrenprotected MasterDetailTreeNode[] children
protected MasterDetailTreeNode parent
protected MasterDetailTreeNode candidateDropTarget
protected DefaultTreeModel treeModel
protected JTree tree
protected MasterDetailTreeNode(MasterDetailTreeNode parent)
public MasterDetailTreeNode[] getChildren()
public void setParent(MasterDetailTreeNode n)
protected JTree getTree()
protected DefaultTreeModel getTreeModel()
protected MasterDetailTreeNode getRootNode()
public void installIntoTreeAsRootNode(JTree tree, JPanel detailPanelContainer, JPanel defaultDetailPanel)
Node.treeModel and makes this the first node
of it. Also sets some properties of the tree such as the cell renderer.
This can only be called on root nodes (where parent==null)detailPanelContainer - panel which should contain the detail panelsdefaultDetailPanel - if no node selected, this panel is shown in detailContainingPanelprotected void deleteNode0(MasterDetailTreeNode node)
protected void informTreeModelThatNodeHasRadicallyChanged()
public TreePath newTreePath()
public void select()
public void redraw()
protected int expandJTreeNode(JTree tree, TreeModel model, MasterDetailTreeNode node, int row)
public void expandAllChildren()
public MasterDetailTreeNode getSelectedNode()
protected abstract MasterDetailTreeNode[] fetchChildren()
public abstract JPanel newDetailJPanel()
public JPopupMenu newPopupMenu()
public abstract ImageIcon getTreeIcon()
public abstract String getTreeText()
public String getExtraText()
public Color getExtraTextColor()
public DataFlavor[] getAcceptableDropFlavors()
public int getAcceptableDropActions()
DnDConstants.ACTION_COPY.public void transferrableHasBeenDropped(DropTargetDropEvent e)
Transferrable is dropped on this node, this method
is called. In the default implementation this should never be reached,
as a default node cannot accept any DataFlavors or accept any actions.public Enumeration<MasterDetailTreeNode> children()
public TreeNode getChildAt(int param)
getChildAt in interface TreeNodepublic int getChildCount()
getChildCount in interface TreeNodeCopyright © 2003–2018. All rights reserved.