本文整理汇总了Java中javax.swing.tree.DefaultTreeModel.setRoot方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTreeModel.setRoot方法的具体用法?Java DefaultTreeModel.setRoot怎么用?Java DefaultTreeModel.setRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.DefaultTreeModel
的用法示例。
在下文中一共展示了DefaultTreeModel.setRoot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refresh
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
/**
* Updates the JTree with class files loaded from the current jar.
*/
public void refresh() {
JarData jar = Recaf.INSTANCE.jarData;
if (jar == null) {
return;
}
// TODO: Expand new tree model to match the original
// Root node
String jarName = (jar.jar != null) ? jar.jar.getName() : "?";
ASMTreeNode root = new ASMTreeNode(jarName, null);
DefaultTreeModel model = new DefaultTreeModel(root);
tree.setModel(model);
// Iterate classes
List<String> names = Streams.sortedNameList(jar.classes.keySet());
for (String className : names) {
if (!jar.classes.containsKey(className)) {
continue;
}
ClassNode node = jar.classes.get(className);
// Create directory path based on current node name.
ArrayList<String> dirPath = new ArrayList<String>(Arrays.asList(node.name.split("/")));
// Create directory of nodes
Swing.generateTreePath(root, dirPath, node, model);
}
model.setRoot(root);
}
示例2: setLogModel
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
public void setLogModel(Model value) {
this.logModel = value;
DefaultTreeModel model = (DefaultTreeModel) getModel();
CircuitNode curRoot = (CircuitNode) model.getRoot();
CircuitState state = logModel == null ? null : logModel.getCircuitState();
if (state == null) {
if (curRoot != null)
model.setRoot(null);
return;
}
if (curRoot == null || curRoot.circuitState != state) {
curRoot = new CircuitNode(null, state, null);
model.setRoot(curRoot);
}
}
示例3: createTreeModel
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
private TreeModel createTreeModel(DocumentModel dm) {
DocumentElement rootElement = dm.getRootElement();
DefaultTreeModel dtm = new DefaultTreeModel(null);
TreeNodeAdapter rootTna = new TreeNodeAdapter(rootElement, dtm, tree, null);
dtm.setRoot(rootTna);
return dtm;
}
示例4: setup
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
/**
* Setup and return the tree model for a search.
*
* @return
*/
private DefaultTreeModel setup() {
JarData jar = Recaf.INSTANCE.jarData;
String jarName = (jar.jar != null) ? jar.jar.getName() : "?";
ASMTreeNode root = new ASMTreeNode(jarName, null);
DefaultTreeModel model = new DefaultTreeModel(root);
model.setRoot(root);
return model;
}