本文整理汇总了Java中javax.swing.tree.DefaultTreeModel.removeNodeFromParent方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTreeModel.removeNodeFromParent方法的具体用法?Java DefaultTreeModel.removeNodeFromParent怎么用?Java DefaultTreeModel.removeNodeFromParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.DefaultTreeModel
的用法示例。
在下文中一共展示了DefaultTreeModel.removeNodeFromParent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refresh
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
private void refresh(DefaultTreeModel m,
ServerStatus.ModuleSummary[] modules) {
final MutableTreeNode root = (MutableTreeNode) m.getRoot();
totalPlayers = 0;
while (root.getChildCount() > 0) {
m.removeNodeFromParent((MutableTreeNode) root.getChildAt(0));
}
if (modules.length == 0) {
final DefaultMutableTreeNode n = new DefaultMutableTreeNode(
Resources.getString("Chat.no_connections")); //$NON-NLS-1$
n.setAllowsChildren(false);
}
else {
for (ServerStatus.ModuleSummary s : modules) {
m.insertNodeInto(createNode(s), root, root.getChildCount());
}
}
// append total number of players on server to root node
root.setUserObject(
Resources.getString(Resources.VASSAL) + " (" + totalPlayers + ")");
}
示例2: run
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
@Override
public void run() {
Thread.currentThread().setUncaughtExceptionHandler(this);
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
DefaultMutableTreeNode child = new DefaultMutableTreeNode("Child");
DefaultTreeModel model = new DefaultTreeModel(root);
this.tree = new JTree();
this.tree.setModel(model);
JFrame frame = new JFrame(getClass().getSimpleName());
frame.add(this.tree);
model.addTreeModelListener(this); // frame is not visible yet
model.insertNodeInto(child, root, root.getChildCount());
model.removeNodeFromParent(child);
frame.setSize(640, 480);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
frame.setVisible(true);
}
示例3: exportDone
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
protected void exportDone(JComponent source, Transferable data, int action) {
if((action & MOVE) == MOVE) {
JTree tree = (JTree)source;
DefaultTreeModel model = (DefaultTreeModel)tree.getModel();
// Remove nodes saved in nodesToRemove in createTransferable.
for(int i = 0; i < nodesToRemove.length; i++) {
model.removeNodeFromParent(nodesToRemove[i]);
}
}
}
示例4: exportDone
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
@Override
protected void exportDone(JComponent source, Transferable data, int action) {
if ((action & MOVE) == MOVE) {
JTree tree = (JTree) source;
DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
// remove nodes saved in nodesToRemove in createTransferable
for (int i = 0; i < nodesToRemove.length; i++) {
model.removeNodeFromParent(nodesToRemove[i]);
}
}
}
示例5: exportDone
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
@Override
protected void exportDone(JComponent source, Transferable data, int action) {
if ((action & MOVE) == MOVE) {
JTree tree = (JTree) source;
DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
// Remove nodes saved in nodesToRemove in createTransferable.
for (DefaultMutableTreeNode nodesToRemove1 : nodesToRemove) {
model.removeNodeFromParent(nodesToRemove1);
}
}
}
示例6: run
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
@Override
public void run(AnActionButton button) {
DefaultMutableTreeNode selectedNode = getSelectedNode();
if (selectedNode != null && selectedNode.getParent() != null) {
// 删除指定节点
DefaultTreeModel model = (DefaultTreeModel) this.templateTree.getModel();
model.removeNodeFromParent(selectedNode);
}
}