当前位置: 首页>>代码示例>>Java>>正文


Java DefaultTreeModel.removeNodeFromParent方法代码示例

本文整理汇总了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 + ")");
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:25,代码来源:ServerStatusView.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:Test8015926.java

示例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]);
        }
    }
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:11,代码来源:TreeTransferHandler.java

示例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]);
        }
    }
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:12,代码来源:RmlTagTreeTransferHandler.java

示例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);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:LastNodeLowerHalfDrop.java

示例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);
    }
}
 
开发者ID:hykes,项目名称:CodeGen,代码行数:10,代码来源:TemplateRemoveAction.java


注:本文中的javax.swing.tree.DefaultTreeModel.removeNodeFromParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。