本文整理匯總了Java中javax.swing.tree.MutableTreeNode.getParent方法的典型用法代碼示例。如果您正苦於以下問題:Java MutableTreeNode.getParent方法的具體用法?Java MutableTreeNode.getParent怎麽用?Java MutableTreeNode.getParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.tree.MutableTreeNode
的用法示例。
在下文中一共展示了MutableTreeNode.getParent方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: insert
import javax.swing.tree.MutableTreeNode; //導入方法依賴的package包/類
@Override
public synchronized void insert(MutableTreeNode child, int index) {
if (!getAllowsChildren())
throw new IllegalStateException("Node does not allow children");
if (!(child instanceof IterationStrategyNode))
throw new IllegalArgumentException(
"Child not an instance of IterationStrategyNode: " + child);
if (child == this)
throw new IllegalArgumentException("Can't be it's own parent");
// Check if it is already there (in case we'll just move it)
int alreadyExistsIndex = children.indexOf(child);
children.add(index, (IterationStrategyNode) child);
if (alreadyExistsIndex > -1) {
// Remove it from the old position
if (index < alreadyExistsIndex
&& alreadyExistsIndex + 1 < children.size())
alreadyExistsIndex++;
children.remove(alreadyExistsIndex);
}
if (child.getParent() != this)
child.setParent(this);
}
示例2: add
import javax.swing.tree.MutableTreeNode; //導入方法依賴的package包/類
protected void add(MutableTreeNode parent,
MutableTreeNode child)
{
if(child.getParent() == parent)
return;
add(this, parent, child);
}
示例3: removeNodeFromParent
import javax.swing.tree.MutableTreeNode; //導入方法依賴的package包/類
@Override
public void removeNodeFromParent(MutableTreeNode node) {
ProjectTreeNode parent = (ProjectTreeNode)node.getParent();
if(parent == null)
throw new IllegalArgumentException("node does not have a parent.");
int[] childIndex = new int[1];
Object[] removedArray = new Object[1];
childIndex[0] = parent.getIndex(node, filterMod, filterSearch);
parent.remove(childIndex[0], filterMod, filterSearch);
removedArray[0] = node;
nodesWereRemoved(parent, childIndex, removedArray);
}
示例4: removeNodeFromParent
import javax.swing.tree.MutableTreeNode; //導入方法依賴的package包/類
@Override
public void removeNodeFromParent(MutableTreeNode node) {
MutableTreeNode parent = (MutableTreeNode) node.getParent();
if(parent == null)
throw new IllegalArgumentException("node does not have a parent.");
int[] childIndex = new int[1];
Object[] removedArray = new Object[1];
childIndex[0] = getIndex(parent, node);
parent.remove(childIndex[0]);
removedArray[0] = node;
nodesWereRemoved(parent, childIndex, removedArray);
}
示例5: remove
import javax.swing.tree.MutableTreeNode; //導入方法依賴的package包/類
@Override
public synchronized void remove(MutableTreeNode node) {
if (!getAllowsChildren())
throw new IllegalStateException("Node does not allow children");
children.remove(node);
if (node.getParent() == this)
node.setParent(null);
}
示例6: insert
import javax.swing.tree.MutableTreeNode; //導入方法依賴的package包/類
@Override
public void insert(MutableTreeNode newChild, int index) {
FontCollectionNode oldParent = (FontCollectionNode) newChild.getParent();
if (oldParent != null) {
oldParent.remove(newChild);
}
newChild.setParent(this);
children.add(index, (FontFamilyNode) newChild);
}
示例7: insert
import javax.swing.tree.MutableTreeNode; //導入方法依賴的package包/類
@Override
public void insert(MutableTreeNode newChild, int index) {
FontFamilyNode oldParent = (FontFamilyNode) newChild.getParent();
if (oldParent != null) {
oldParent.remove(newChild);
}
newChild.setParent(this);
children.add(index, (FontFaceNode) newChild);
}
示例8: removeNodeFromParent
import javax.swing.tree.MutableTreeNode; //導入方法依賴的package包/類
@Override
public synchronized void removeNodeFromParent(MutableTreeNode node) {
if (node.getParent() != null)
super.removeNodeFromParent(node);
}