當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。