本文整理了Java中javax.swing.JTree.setModel()
方法的一些代码示例,展示了JTree.setModel()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.setModel()
方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:setModel
暂无
代码示例来源:origin: deathmarine/Luyten
loadNodesByNames(top, list);
tree.setModel(new DefaultTreeModel(top));
代码示例来源:origin: SonarSource/sonarqube
componentTree.setModel(new DefaultTreeModel(
new DefaultMutableTreeNode("empty") {
代码示例来源:origin: deathmarine/Luyten
tree.setModel(new DefaultTreeModel(top));
代码示例来源:origin: SonarSource/sonarqube
private void loadComponents() {
int rootComponentRef = metadata.getRootComponentRef();
Component component = reader.readComponent(rootComponentRef);
DefaultMutableTreeNode project = createNode(component);
loadChildren(component, project);
getComponentTree().setModel(new DefaultTreeModel(project));
}
代码示例来源:origin: pmd/pmd
/**
* @see ViewerModelListener#viewerModelChanged(ViewerModelEvent)
*/
@Override
public void viewerModelChanged(ViewerModelEvent e) {
switch (e.getReason()) {
case ViewerModelEvent.CODE_RECOMPILED:
tree.setModel(new ASTModel(model.getRootNode()));
break;
case ViewerModelEvent.NODE_SELECTED:
if (e.getSource() != this) {
List<Node> list = new ArrayList<>();
for (Node n = (Node) e.getParameter(); n != null; n = n.jjtGetParent()) {
list.add(n);
}
Collections.reverse(list);
TreePath path = new TreePath(list.toArray());
tree.setSelectionPath(path);
tree.scrollPathToVisible(path);
}
break;
default:
// Do nothing
break;
}
}
代码示例来源:origin: deathmarine/Luyten
public void closeFile() {
for (OpenFile co : hmap) {
int pos = house.indexOfTab(co.name);
if (pos >= 0)
house.remove(pos);
co.close();
}
final State oldState = state;
Model.this.state = null;
if (oldState != null) {
Closer.tryClose(oldState);
}
hmap.clear();
tree.setModel(new DefaultTreeModel(null));
metadataSystem = new MetadataSystem(typeLoader);
file = null;
treeExpansionState = null;
open = false;
mainWindow.onFileLoadEnded(file, open);
}
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Removes all files from the panel
*/
public void clearAll() {
TreeReaderFactory oldTrf = treeModel.getTRF();//Preserve the current TRF when we refresh the tree file list
FileTreeNode root = new FileTreeNode();
treeModel = new FileTreeModel(root);
setTreeReaderFactory(oldTrf);
tree.setModel(treeModel);
this.revalidate();
this.repaint();
}
代码示例来源:origin: runelite/runelite
private void refreshWidgets()
{
clientThread.invokeLater(() ->
{
Widget[] rootWidgets = client.getWidgetRoots();
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
overlay.setWidget(null);
overlay.setItemIndex(-1);
for (Widget widget : rootWidgets)
{
DefaultMutableTreeNode childNode = addWidget("R", widget);
if (childNode != null)
{
root.add(childNode);
}
}
SwingUtilities.invokeLater(() ->
{
overlay.setWidget(null);
overlay.setItemIndex(-1);
refreshInfo();
widgetTree.setModel(new DefaultTreeModel(root));
});
});
}
代码示例来源:origin: deathmarine/Luyten
return;
tree.setModel(new DefaultTreeModel(null));
TreeNodeUserObject topNodeUserObject = new TreeNodeUserObject(getName(file.getName()));
final DefaultMutableTreeNode top = new DefaultMutableTreeNode(topNodeUserObject);
tree.setModel(new DefaultTreeModel(top));
settings.setTypeLoader(new InputTypeLoader());
open = true;
代码示例来源:origin: deathmarine/Luyten
tree.setModel(new DefaultTreeModel(null));
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.setCellRenderer(new CellRenderer());
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Construct a CategoryExplorerTree and create a default CategoryExplorerModel.
*/
public CategoryExplorerTree() {
super();
CategoryNode rootNode = new CategoryNode("Categories");
_model = new CategoryExplorerModel(rootNode);
setModel(_model);
init();
}
代码示例来源:origin: pentaho/mondrian
public void setMetaData(JdbcMetaData jdbcMetaData) {
try {
this.jdbcMetaData = jdbcMetaData;
Node rootNode = new Node(null, NodeType.ROOT, null);
root = new DefaultMutableTreeNode(rootNode);
for (String schemaName : jdbcMetaData.getAllSchemas()) {
Node cat = new Node(schemaName, NodeType.CATALOG, null);
DefaultMutableTreeNode catTreeNode =
new DefaultMutableTreeNode(cat);
cat.treeNode = catTreeNode;
root.add(catTreeNode);
List<String> tables = jdbcMetaData.getAllTables(schemaName);
for (String tableName : tables) {
Node table = new Node(tableName, NodeType.TABLE, null);
DefaultMutableTreeNode tableTreeNode =
new DefaultMutableTreeNode(table);
table.treeNode = tableTreeNode;
catTreeNode.add(tableTreeNode);
}
cat.gotChildren = true;
}
rootNode.gotChildren = true;
treeModel = new DefaultTreeModel(root, true);
tree.setModel(treeModel);
tree.addTreeWillExpandListener(this);
updater = new JTreeUpdater(tree);
} catch (Exception ex) {
LOGGER.error(ex);
}
}
代码示例来源:origin: pentaho/mondrian
tree.setModel(model);
tree.setCellRenderer(renderer);
tree.addTreeSelectionListener(this);
代码示例来源:origin: locationtech/jts
public GeometryTreePanel() {
// default empty model
tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("No geometry shown")));
//((DefaultMutableTreeNode) (tree.getRoot())).removeAllChildren();
try {
initUI();
} catch (Exception ex) {
ex.printStackTrace();
}
}
代码示例来源:origin: igniterealtime/Spark
/**
* Initialize the jtree for the UI. Sets the model and adds the PrivacyLists
* to the model using loadPrivacyLists()
*
*/
private void initializeTree() {
_model = new DefaultTreeModel(_top);
_tree.setModel(_model);
loadPrivacyLists();
_tree.expandRow(0);
}
代码示例来源:origin: igvteam/igv
public Ga4ghLoadDialog(Frame owner, Ga4ghProvider[] providers) {
super(owner);
initComponents();
this.providers = providers;
treeModel = new DefaultTreeModel(createNodes(providers));
this.selectionTree.setModel(treeModel);
}
代码示例来源:origin: org.junit/com.springsource.junit
/**
* Shows the test hierarchy starting at the given test
*/
public void showTestTree(Test root) {
fModel= new TestTreeModel(root);
fTree.setModel(fModel);
fTree.setCellRenderer(new TestTreeCellRenderer());
}
代码示例来源:origin: org.junit/com.springsource.junit
public TestSuitePanel() {
super(new BorderLayout());
setPreferredSize(new Dimension(300, 100));
fTree= new JTree();
fTree.setModel(null);
fTree.setRowHeight(20);
ToolTipManager.sharedInstance().registerComponent(fTree);
fTree.putClientProperty("JTree.lineStyle", "Angled");
fScrollTree= new JScrollPane(fTree);
add(fScrollTree, BorderLayout.CENTER);
}
代码示例来源:origin: org.apache.log4j/com.springsource.org.apache.log4j
/**
* Construct a CategoryExplorerTree and create a default CategoryExplorerModel.
*/
public CategoryExplorerTree() {
super();
CategoryNode rootNode = new CategoryNode("Categories");
_model = new CategoryExplorerModel(rootNode);
setModel(_model);
init();
}
代码示例来源:origin: edu.stanford.nlp/stanford-corenlp
/**
* Removes all files from the panel
*/
public void clearAll() {
TreeReaderFactory oldTrf = treeModel.getTRF();//Preserve the current TRF when we refresh the tree file list
FileTreeNode root = new FileTreeNode();
treeModel = new FileTreeModel(root);
setTreeReaderFactory(oldTrf);
tree.setModel(treeModel);
this.revalidate();
this.repaint();
}
内容来源于网络,如有侵权,请联系作者删除!