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


Java DefaultMutableTreeNode.setAllowsChildren方法代码示例

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


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

示例1: refresh

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的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: generateFlatModel

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private DefaultMutableTreeNode generateFlatModel(ClusterModel cm) {
	DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("root");
	rootNode.setAllowsChildren(true);
	for (int i = 0; i < cm.getNumberOfClusters(); i++) {
		Cluster cl = cm.getCluster(i);
		DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(cl);
		newNode.setAllowsChildren(true);
		rootNode.add(newNode);
		for (Object exampleId : cl.getExampleIds()) {
			newNode.add(createLeaf(exampleId));
		}
	}
	return rootNode;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:15,代码来源:ClusterTreeVisualization.java

示例3: generateTreeModel

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private DefaultMutableTreeNode generateTreeModel(HierarchicalClusterNode cl) {
	DefaultMutableTreeNode result = new DefaultMutableTreeNode(cl);
	result.setAllowsChildren(true);

	// Add sub clusters
	for (HierarchicalClusterNode subNode : cl.getSubNodes()) {
		result.add(generateTreeModel(subNode));
	}

	// Add objects
	for (Object exampleId : cl.getExampleIdsInSubtree()) {
		result.add(createLeaf(exampleId));
	}
	return result;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:16,代码来源:ClusterTreeVisualization.java

示例4: createLeaf

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private MutableTreeNode createLeaf(Object id) {
	ObjectVisualizer viz = ObjectVisualizerService.getVisualizerForObject(clusterModel);
	String title = viz.getTitle(id);
	if (title == null) {
		if (id instanceof String) {
			title = (String) id;
		} else {
			title = ((Integer) id).toString();
		}
	}
	DefaultMutableTreeNode newLeaf = new DefaultMutableTreeNode(new ClusterTreeLeaf(title, id));
	newLeaf.setAllowsChildren(false);
	return newLeaf;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:15,代码来源:ClusterTreeVisualization.java

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