本文整理汇总了Java中javax.swing.JTree.setModel方法的典型用法代码示例。如果您正苦于以下问题:Java JTree.setModel方法的具体用法?Java JTree.setModel怎么用?Java JTree.setModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTree
的用法示例。
在下文中一共展示了JTree.setModel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateJTree
import javax.swing.JTree; //导入方法依赖的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;
}
示例2: installFilteringModel
import javax.swing.JTree; //导入方法依赖的package包/类
/**Install a filtering model to the given tree, using given model as the source
* of the data.
*
* @param tree to which the model should be installed
* @param source source {@link TreeModel} - the data to show will be gathered from this model
* @param acceptor acceptor specifying whether the given original tree node should or should not
* be visible for given user's filter
* @param delegatingTreeModelListeners is allowing to delegate tree model listeners to tree
*/
public void installFilteringModel(JTree tree, TreeModel source, Acceptor acceptor, boolean delegatingTreeModelListeners) {
if (!SwingUtilities.isEventDispatchThread()) {
throw new IllegalStateException("Not in AWT Event Dispatch Thread");
}
usedCallback.run();
tree.setModel(new FilteringTreeModel(source, doc, acceptor, delegatingTreeModelListeners));
}