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


Java DefaultMutableTreeNode.add方法代码示例

本文整理汇总了Java中javax.swing.tree.DefaultMutableTreeNode.add方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMutableTreeNode.add方法的具体用法?Java DefaultMutableTreeNode.add怎么用?Java DefaultMutableTreeNode.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.tree.DefaultMutableTreeNode的用法示例。


在下文中一共展示了DefaultMutableTreeNode.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRoot

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public static TreeNode getRoot() {
    DefaultMutableTreeNode node = new DefaultMutableTreeNode("root");
    DefaultMutableTreeNode first = new DefaultMutableTreeNode("first");
    DefaultMutableTreeNode second = new DefaultMutableTreeNode("second");
    DefaultMutableTreeNode third = new DefaultMutableTreeNode("third");

    first.add(new DefaultMutableTreeNode("1.1"));
    first.add(new DefaultMutableTreeNode("1.2"));
    first.add(new DefaultMutableTreeNode("1.3"));

    second.add(new DefaultMutableTreeNode("2.1"));
    second.add(new DefaultMutableTreeNode("2.2"));
    second.add(new DefaultMutableTreeNode("2.3"));

    third.add(new DefaultMutableTreeNode("3.1"));
    third.add(new DefaultMutableTreeNode("3.2"));
    third.add(new DefaultMutableTreeNode("3.3"));

    node.add(first);
    node.add(second);
    node.add(third);

    return node;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:Test4631471.java

示例2: traverseFileSystem

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private void traverseFileSystem(Entry poifsNode, DefaultMutableTreeNode treeNode) throws TreeModelLoadException {
	final String qualifier;
	if (poifsNode.getParent() == null) {
		qualifier = "OLERootEntry";
	} else if (poifsNode instanceof DirectoryNode) {
		qualifier = "OLEDirEntry";
	} else {
		qualifier = "OLEEntry";
	}

	treeNode.setUserObject(appContext.getBean(qualifier, poifsNode, treeNode));
	if (poifsNode instanceof DirectoryNode) {
		for (Entry poifsChild : ((DirectoryNode)poifsNode)) {
			DefaultMutableTreeNode treeChild = new DefaultMutableTreeNode();
			treeNode.add(treeChild);
			traverseFileSystem(poifsChild, treeChild);
		}
	}
}
 
开发者ID:kiwiwings,项目名称:poi-visualizer,代码行数:20,代码来源:OLETreeModel.java

示例3: createDeviceNode

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private DefaultMutableTreeNode createDeviceNode(Device device) {
    DefaultMutableTreeNode dmtNode = new DefaultMutableTreeNode("Device" + valueDivider + device.getType());

    String tag = device.getTag();
    if (tag != null && !tag.isEmpty()) {
        dmtNode.add(new DefaultMutableTreeNode("tag" + valueDivider + tag));
    }

    String mandatory = device.getMandatory();
    if (mandatory != null && !mandatory.isEmpty()) {
        dmtNode.add(new DefaultMutableTreeNode("mandatory" + valueDivider + mandatory));
    }

    String anInterface = device.getInterface();
    if (anInterface != null && !anInterface.isEmpty()) {
        dmtNode.add(new DefaultMutableTreeNode("Interface" + valueDivider + anInterface));
    }

    List<Extension> extensions = device.getExtension();
    for (Extension extension : extensions) {
        dmtNode.add(createExtensionNode(extension));
    }

    List<Instance> instances = device.getInstance();
    for (Instance instance : instances) {
        dmtNode.add(createInstanceNode(instance));
    }

    return dmtNode;
}
 
开发者ID:phweda,项目名称:MFM,代码行数:31,代码来源:MAMEtoJTree.java

示例4: loadTextProp

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private void loadTextProp(final DefaultMutableTreeNode parentNode, String name, List<TextPropCollection> props) {
	final DefaultMutableTreeNode childNode = new DefaultMutableTreeNode();
	final HSLFNamedEntry childNE = appContext.getBean(HSLFNamedEntry.class, name, childNode);
	childNode.setUserObject(childNE);
	parentNode.add(childNode);
	int textBegin = 0;
	for (TextPropCollection tpc : props) {
		final int textEnd = textBegin+tpc.getCharactersCovered();
		final DefaultMutableTreeNode textNode = new DefaultMutableTreeNode();
		final HSLFNamedEntry textNE = appContext.getBean(HSLFNamedEntry.class, textBegin+"-"+textEnd+" (i"+tpc.getIndentLevel()+")", textNode);
		textNode.setUserObject(textNE);
		childNode.add(textNode);
		textBegin = textEnd;
		for (TextProp tp : tpc.getTextPropList()) {
			final DefaultMutableTreeNode propNode = new DefaultMutableTreeNode();
			final HSLFTextPropEntry propEntry = appContext.getBean(HSLFTextPropEntry.class, tp, propNode);
			propNode.setUserObject(propEntry);
			textNode.add(propNode);
		}
	}
}
 
开发者ID:kiwiwings,项目名称:poi-visualizer,代码行数:22,代码来源:HSLFTreeModel.java

示例5: getDefaultMutableTreeNodeOfHashMap

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public static DefaultMutableTreeNode getDefaultMutableTreeNodeOfHashMap(TreeArrayList<?> data, DefaultMutableTreeNode top) {
    if(data == null) {
        return top;
    }
    DefaultMutableTreeNode top_new = new DefaultMutableTreeNode(data.object);
    if(top != null) {
        top.add(top_new);
    } else {
        top = top_new;
    }
    try {
        for(Object o : data) {
            if(o instanceof TreeArrayList) {
                getDefaultMutableTreeNodeOfHashMap((TreeArrayList) o, top_new);
            } else {
                top_new.add(new DefaultMutableTreeNode(o));
            }
        }
    } catch (Exception ex) {
    }
    return top;
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:23,代码来源:JTreeUtils.java

示例6: init

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public void init() {
    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
    root.removeAllChildren();
    for (String availableExchangeName : availableExchangeNames) {
        DefaultMutableTreeNode firstChild = new DefaultMutableTreeNode(availableExchangeName);
        Collection<CurrencyPair> currencyPairs = IdeaCurrencyApp.getInstance().getCurrencyPairs(availableExchangeName);
        for (CurrencyPair currencyPair : currencyPairs) {
            CheckedTreeNode secondChild = new CheckedTreeNode(currencyPair.toString());
            boolean selected = isSelected(availableExchangeName, currencyPair);
            secondChild.setChecked(selected);
            firstChild.add(secondChild);
            tree.expandPath(new TreePath(secondChild));
        }
        tree.expandPath(new TreePath(firstChild));
        root.add(firstChild);
    }
    model.reload();
    tree.treeDidChange();
    Util.expandAll(tree, new TreePath(root), true);
}
 
开发者ID:semihunaldi,项目名称:IdeaCurrency,代码行数:22,代码来源:IdeaCurrencyConfigUI.java

示例7: buildTree

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
 * Builds the JTree which represents the navigation menu and then
 * returns it
 *
 * @param group The {@code OptionGroup} to build from.
 * @param parent The tree to build onto.
 */
private void buildTree(OptionGroup group, DefaultMutableTreeNode parent) {
    for (Option option : group.getOptions()) {
        if (option instanceof OptionGroup) {
            if (!((OptionGroup)option).isVisible()) continue;
            DefaultMutableTreeNode branch
                = new DefaultMutableTreeNode(option);
            parent.add(branch);
            buildTree((OptionGroup) option, branch);
        }
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:19,代码来源:OptionGroupUI.java

示例8: create

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private static DefaultMutableTreeNode create(String name, String... values) {
    DefaultMutableTreeNode node = new DefaultMutableTreeNode(name);
    for (String value : values) {
        node.add(create(value));
    }
    return node;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:Test8013571.java

示例9: loadPictures

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private void loadPictures(final DefaultMutableTreeNode parentNode) {
	for (HSLFPictureData p : ppt.getPictureData()) {
		final DefaultMutableTreeNode childNode = new DefaultMutableTreeNode();
		final HSLFPictureEntry pic = appContext.getBean(HSLFPictureEntry.class, p, childNode);
		childNode.setUserObject(pic);
		parentNode.add(childNode);
	}

}
 
开发者ID:kiwiwings,项目名称:poi-visualizer,代码行数:10,代码来源:HSLFTreeModel.java

示例10: addNodes

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/** Add nodes from under "dir" into curTop. Highly recursive. */
DefaultMutableTreeNode addNodes(DefaultMutableTreeNode curTop, File dir) {
  String curPath = dir.getName();
  DefaultMutableTreeNode curDir = new DefaultMutableTreeNode(curPath);
  if (curTop != null) { // should only be null at root
    curTop.add(curDir);
  }
  Vector ol = new Vector();
  String[] tmp = dir.list();
  for (int i = 0; i < tmp.length; i++)
    ol.addElement(tmp[i]);
  Collections.sort(ol, String.CASE_INSENSITIVE_ORDER);
  File f;
  Vector files = new Vector();
  // Make two passes, one for Dirs and one for Files. This is #1.
  for (int i = 0; i < ol.size(); i++) {
    String thisObject = (String) ol.elementAt(i);
    String newPath;
    if (curPath.equals("."))
      newPath = thisObject;
    else
      newPath = curPath + File.separator + thisObject;
    if ((f = new File(newPath)).isDirectory())
      addNodes(curDir, f);
    else{
  	String extension = ""+thisObject.charAt(thisObject.length()-3)+
  						  thisObject.charAt(thisObject.length()-2)+
  						  thisObject.charAt(thisObject.length()-1);
  	if(extension.equals("apl"))
  		files.addElement(thisObject);
      
    	}
  }
  // Pass two: for files.
  for (int fnum = 0; fnum < files.size(); fnum++)
    curDir.add(new DefaultMutableTreeNode(files.elementAt(fnum)));
  return curDir;
}
 
开发者ID:BlidiWajdi,项目名称:Mujeed-Arabic-Prolog,代码行数:39,代码来源:FileTree.java

示例11: createChildren

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private void createChildren(File fileRoot, DefaultMutableTreeNode node){
    File[] files = fileRoot.listFiles();
    if (files == null) return ;
    
    for (File file : files) {
        DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(new FileNode(file));
        node.add(childNode);
        if (file.isDirectory()){
            createChildren(file, childNode);
        }
    }
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:13,代码来源:FileBrowser.java

示例12: addResultTreeNode

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
 * This method is used to add nodes to a tree
 *
 * @param node
 *            - the node to be added to
 * @param categoryName
 *            - the group name of the list of the items
 * @param counts
 *            - list of counts values
 */
private void addResultTreeNode(final DefaultMutableTreeNode node, final String categoryName,
                               final List<ModifiedPropertyCountData> counts) {
	final DefaultMutableTreeNode category = new DefaultMutableTreeNode(categoryName);
	node.add(category);

	for (final ModifiedPropertyCountData count : counts) {
		final DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(ResultsFormatter.formatCount(count));
		category.add(childNode);
	}
}
 
开发者ID:orionhealth,项目名称:rlc-analyser,代码行数:21,代码来源:RLCTreeBuilder.java

示例13: createAndShowGUI

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private static void createAndShowGUI() {
    try {
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
    DefaultMutableTreeNode item = new DefaultMutableTreeNode("item");
    DefaultMutableTreeNode subItem = new DefaultMutableTreeNode("subItem");

    root.add(item);
    item.add(subItem);

    DefaultTreeModel model = new DefaultTreeModel(root);
    tree = new JTree(model);

    tree.setCellEditor(new Editor());
    tree.setEditable(true);
    tree.setRowHeight(30);
    tree.setCellRenderer(new CheckboxCellRenderer());

    JFrame frame = new JFrame("bug8023474");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(tree));
    frame.setSize(400, 300);
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:bug8023474.java

示例14: main

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public static void main(final String[] args) {
    final DefaultMutableTreeNode root = new DefaultMutableTreeNode(new CheckBoxNodeData("Root", Boolean.TRUE));

    final DefaultMutableTreeNode accessibility =
        add(root, "Accessibility", true);
    add(accessibility, "Move system caret with focus/selection changes", false);
    add(accessibility, "Always expand alt text for images", true);
    root.add(accessibility);

    final DefaultMutableTreeNode browsing =
        new DefaultMutableTreeNode(new CheckBoxNodeData("Browsing", null));
    add(browsing, "Notify when downloads complete", true);
    add(browsing, "Disable script debugging", true);
    add(browsing, "Use AutoComplete", true);
    add(browsing, "Browse in a new process", false);
    root.add(browsing);

    final CheckBoxTree tree = new CheckBoxTree(root);
    ((DefaultMutableTreeNode) tree.getModel().getRoot()).add(new DefaultMutableTreeNode(new CheckBoxNodeData("gggg", null)));
    ((DefaultTreeModel) tree.getModel()).reload();
    // listen for changes in the selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(final TreeSelectionEvent e) {
            //System.out.println("selection changed");
        }
    });
    // show the tree on screen
    final JFrame frame = new JFrame("CheckBox Tree");
    final JScrollPane scrollPane = new JScrollPane(tree);
    frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(300, 150);
    frame.setVisible(true);
}
 
开发者ID:berniejenny,项目名称:MapAnalyst,代码行数:36,代码来源:CheckBoxTree.java

示例15: createNode

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private DefaultMutableTreeNode createNode(Object o) {
  Object[] children = null;
  if (o instanceof ServerStatus.ModuleSummary) {
    final ServerStatus.ModuleSummary ms = (ServerStatus.ModuleSummary) o;

    children = ms.getRooms();

    final int players = ms.numPlayers();
    ms.setModuleName(ms.getModuleName() + " (" + players + ")");
    totalPlayers += players;
  }
  else if (o instanceof SimpleRoom) {
    final SimpleRoom r = (SimpleRoom) o;

    final List<Player> l = r.getPlayerList();

    // append the number of players to each room name
    r.setName(r.getName() + " (" + l.size() + ")");
    children = l.toArray(new Player[l.size()]);
  }

  final DefaultMutableTreeNode node = new DefaultMutableTreeNode(o);

  if (children != null) {
    for (Object c : children) {
      node.add(createNode(c));
    }
  }

  node.setAllowsChildren(children != null);
  return node;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:33,代码来源:ServerStatusView.java


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