public class DefaultMutableTreeModel extends javax.swing.tree.DefaultTreeModel implements MutableTreeModel
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Object[] |
childTypes |
static java.awt.datatransfer.DataFlavor |
listFlavor |
static java.awt.datatransfer.DataFlavor |
objectFlavor |
| Constructor and Description |
|---|
DefaultMutableTreeModel()
Constructs a new DefaultMutableTreeModel using a
DefaultMutableTreeNode as root of the tree.
|
DefaultMutableTreeModel(javax.swing.tree.TreeNode root)
Constructs a new DefaultMutableTreeModel using the given tree node
as the root of the tree.
|
| Modifier and Type | Method and Description |
|---|---|
javax.swing.tree.TreePath |
createNodeAt(java.lang.Object type,
javax.swing.tree.MutableTreeNode parent,
int index)
Invoke this to insert a new child at location index in parents children.
|
java.awt.datatransfer.Transferable |
exportTransferable(javax.swing.tree.MutableTreeNode[] nodes)
Creates a Transferable to use as the source for a data
transfer of the specified elements.
|
java.lang.Object |
getCreatableNodeType(java.lang.Object node)
Returns the type of children that may be created at
this node.
|
java.lang.Object[] |
getCreatableNodeTypes(java.lang.Object node)
Returns the type of children that may be created at
this node.
|
javax.swing.Action[] |
getNodeActions(javax.swing.tree.MutableTreeNode[] nodes)
Gets actions for the indicated nodes.
|
int |
importTransferable(java.awt.datatransfer.Transferable t,
int action,
javax.swing.tree.MutableTreeNode parent,
int index)
Causes a transfer to the model from a clipboard or
a DND drop operation.
|
int |
insertAllInto(java.util.List l,
javax.swing.tree.MutableTreeNode parent,
int index) |
void |
insertNodeInto(javax.swing.tree.MutableTreeNode newChild,
javax.swing.tree.MutableTreeNode parent,
int index) |
boolean |
isEditable()
Gets the editable state of the model.
|
boolean |
isEnabled()
Gets the enabled state of the model.
|
boolean |
isImportable(java.awt.datatransfer.DataFlavor[] transferFlavors,
int action,
javax.swing.tree.MutableTreeNode parent,
int index)
Indicates whether the model would accept an import of the
given set of data flavors prior to actually attempting
to import it.
|
boolean |
isNodeAddable(javax.swing.tree.MutableTreeNode parent,
int index)
Returns whether a node may be added.
|
boolean |
isNodeEditable(javax.swing.tree.MutableTreeNode node)
Returns wether the specified node may be renamed.
|
boolean |
isNodeRemovable(javax.swing.tree.MutableTreeNode node)
Returns wether the specified node may be removed.
|
void |
removeNode(javax.swing.tree.MutableTreeNode node)
Removes a child from its parent.
|
void |
setEditable(boolean b)
Sets the editable state of the model.
|
void |
setEnabled(boolean b)
Sets the enabled state of the model.
|
protected void |
setInsertableNodeTypes(java.lang.Object[] childTypes)
Sets the node types to be returned by getInsertableNodeTypes.
|
void |
setRoot(javax.swing.tree.TreeNode aRoot)
Sets the root to
root. |
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, valueForPathChangedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitremoveNodeFromParentprotected java.lang.Object[] childTypes
public static final java.awt.datatransfer.DataFlavor listFlavor
public static final java.awt.datatransfer.DataFlavor objectFlavor
public DefaultMutableTreeModel()
public DefaultMutableTreeModel(javax.swing.tree.TreeNode root)
public javax.swing.tree.TreePath createNodeAt(java.lang.Object type,
javax.swing.tree.MutableTreeNode parent,
int index)
throws java.lang.IllegalStateException
createNodeAt in interface MutableTreeModeltype - the type of the new child to be created.parent - a node from the tree, obtained from this data source.index - index of the child.java.lang.IllegalStateException - if the parent node does not allow children.public void insertNodeInto(javax.swing.tree.MutableTreeNode newChild,
javax.swing.tree.MutableTreeNode parent,
int index)
insertNodeInto in class javax.swing.tree.DefaultTreeModelpublic java.lang.Object[] getCreatableNodeTypes(java.lang.Object node)
getCreatableNodeTypes in interface MutableTreeModelnode - a node from the tree, obtained from this data source.public java.lang.Object getCreatableNodeType(java.lang.Object node)
getCreatableNodeType in interface MutableTreeModelnode - a node from the tree, obtained from this data source.public boolean isEditable()
public boolean isEnabled()
public boolean isNodeAddable(javax.swing.tree.MutableTreeNode parent,
int index)
MutableTreeModelisNodeAddable in interface MutableTreeModelparent - a node from the tree, obtained from this data source.index - the insertion index.public boolean isNodeRemovable(javax.swing.tree.MutableTreeNode node)
isNodeRemovable in interface MutableTreeModelnode - a node from the tree, obtained from this data source.public boolean isNodeEditable(javax.swing.tree.MutableTreeNode node)
isNodeEditable in interface MutableTreeModelnode - a node from the tree, obtained from this data source.public void removeNode(javax.swing.tree.MutableTreeNode node)
node - a node from the tree, obtained from this data source.public void setEditable(boolean b)
public void setEnabled(boolean b)
protected void setInsertableNodeTypes(java.lang.Object[] childTypes)
public void setRoot(javax.swing.tree.TreeNode aRoot)
root. This will throw an
IllegalArgumentException if root is null.setRoot in class javax.swing.tree.DefaultTreeModelpublic boolean isImportable(java.awt.datatransfer.DataFlavor[] transferFlavors,
int action,
javax.swing.tree.MutableTreeNode parent,
int index)
isImportable in interface MutableTreeModeltransferFlavors - the data formats availableaction - the action, this is either COPY, MOVE or LINK.parent - a node from the tree, obtained from this data source.index - The insertion point.public java.awt.datatransfer.Transferable exportTransferable(javax.swing.tree.MutableTreeNode[] nodes)
MutableTreeModelexportTransferable in interface MutableTreeModelnodes - The nodes.public int importTransferable(java.awt.datatransfer.Transferable t,
int action,
javax.swing.tree.MutableTreeNode parent,
int index)
throws java.awt.datatransfer.UnsupportedFlavorException,
java.io.IOException
MutableTreeModelimportTransferable in interface MutableTreeModelt - The transfer data.parent - a node from the tree, obtained from this data source.index - The insertion point.java.awt.datatransfer.UnsupportedFlavorExceptionjava.io.IOExceptionpublic int insertAllInto(java.util.List l,
javax.swing.tree.MutableTreeNode parent,
int index)
public javax.swing.Action[] getNodeActions(javax.swing.tree.MutableTreeNode[] nodes)
getNodeActions in interface MutableTreeModelnodes - The nodes.