本文整理汇总了Java中javax.swing.tree.DefaultTreeModel.reload方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTreeModel.reload方法的具体用法?Java DefaultTreeModel.reload怎么用?Java DefaultTreeModel.reload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.DefaultTreeModel
的用法示例。
在下文中一共展示了DefaultTreeModel.reload方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的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);
}
示例2: updateJTree
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
public static JTree updateJTree(JTree tree, TreeArrayList<?> data, ExpandedPaths ep) {
ArrayList<String> expanded_paths = null;
TreePath[] paths = null;
if(ep != null) {
expanded_paths = ep.getExpandedPaths(tree);
paths = tree.getSelectionPaths();
}
DefaultMutableTreeNode top = getDefaultMutableTreeNodeOfHashMap(data);
DefaultTreeModel model = new DefaultTreeModel(top);
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
model.reload(root);
tree.setModel(model);
if(ep != null) {
ep.expandPaths(tree, expanded_paths);
tree.setSelectionPaths(paths);
}
return tree;
}
示例3: sortTree
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public static void sortTree(PnlGuiConfig pnlGuiConfig, DefaultMutableTreeNode root, JTree treeTypes) {
if (root != null) {
Enumeration e = root.depthFirstEnumeration();
while (e.hasMoreElements()) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
if (!node.isLeaf()) {
sort(node); //selection sort
}
}
//Atualizando a arvore
if (updateTree) {
TreePath treePath = treeTypes.getSelectionPath();
DefaultTreeModel model = (DefaultTreeModel) treeTypes.getModel();
model.reload();
treeTypes.setSelectionPath(treePath);
updateTree = false;
}
pnlGuiConfig.getPnlFieldCondition().ckDynamicClick();
}
}
示例4: moveWithChildren
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
private void moveWithChildren(RelationTypeNode node, RelationTypeNode siblingNode, RelationTypeNode parent, int index) {
final List<RelationTypeNode> children = new ArrayList<>();
if (siblingNode.getChildCount() > 0) {
Enumeration en = siblingNode.breadthFirstEnumeration();
while (en.hasMoreElements()) {
RelationTypeNode item = (RelationTypeNode) en.nextElement();
children.add(item);
}
siblingNode.removeAllChildren();
}
parent.insert(siblingNode, index);
children.forEach(i -> siblingNode.add(i));
final DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
model.reload(parent);
tree.setSelectedNode(node);
}