List of usage examples for javax.swing.tree DefaultMutableTreeNode getUserObject
public Object getUserObject()
From source file:SortTreeDemo.java
protected void fillModel(SortTreeModel model, DefaultMutableTreeNode current) { PrettyFile pf = (PrettyFile) current.getUserObject(); File f = pf.getFile();/*w ww . ja v a 2s .com*/ if (f.isDirectory()) { String files[] = f.list(); // ignore "." files for (int i = 0; i < files.length; i++) { if (files[i].startsWith(".")) continue; PrettyFile tmp = new PrettyFile(pf, files[i]); DefaultMutableTreeNode node = new DefaultMutableTreeNode(tmp); model.insertNodeInto(node, current); if (tmp.getFile().isDirectory()) { fillModel(model, node); } } } }
From source file:Main.java
private int childIndex(final DefaultMutableTreeNode node, final String childValue) { Enumeration<DefaultMutableTreeNode> children = node.children(); DefaultMutableTreeNode child = null; int index = -1; while (children.hasMoreElements() && index < 0) { child = children.nextElement();/* w w w. ja v a 2 s . c o m*/ if (child.getUserObject() != null && childValue.equals(child.getUserObject())) { index = node.getIndex(child); } } return index; }
From source file:Main.java
public TestPane() { setLayout(new BorderLayout()); tree = new JTree(); File rootFile = new File("."); DefaultMutableTreeNode root = new DefaultMutableTreeNode(rootFile); model = new DefaultTreeModel(root); tree.setModel(model);// w w w .j a v a2s . c om tree.setRootVisible(true); tree.setShowsRootHandles(true); add(new JScrollPane(tree)); JButton load = new JButton("Load"); add(load, BorderLayout.SOUTH); load.addActionListener(e -> { DefaultMutableTreeNode r = (DefaultMutableTreeNode) model.getRoot(); root.removeAllChildren(); model.reload(); File f = (File) r.getUserObject(); addFiles(f, model, r); tree.expandPath(new TreePath(r)); }); }
From source file:it.unibas.spicygui.controllo.tree.ActionViewAllVirtualNode.java
public void actionPerformed(ActionEvent e) { for (int i = 0; i < albero.getRowCount(); i++) { TreePath path = albero.getPathForRow(i); DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) path.getLastPathComponent(); TreeNodeAdapter adapter = (TreeNodeAdapter) treeNode.getUserObject(); adapter.toggleFlagVirtual();// ww w.j av a 2 s.com } albero.updateUI(); }
From source file:it.unibas.spicygui.controllo.tree.ActionViewProvenance.java
public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) albero.getLastSelectedPathComponent(); TreeNodeAdapter adapter = (TreeNodeAdapter) treeNode.getUserObject(); adapter.toggleProvenance();/*from ww w .j a v a2s . c o m*/ albero.updateUI(); }
From source file:it.unibas.spicygui.controllo.tree.ActionViewSkolemFunctor.java
public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) albero.getLastSelectedPathComponent(); TreeNodeAdapter adapter = (TreeNodeAdapter) treeNode.getUserObject(); adapter.toggleSkolem();/* w ww .j av a 2 s. c o m*/ albero.updateUI(); }
From source file:it.unibas.spicygui.controllo.tree.ActionViewAllProvenance.java
public void actionPerformed(ActionEvent e) { for (int i = 0; i < albero.getRowCount(); i++) { TreePath path = albero.getPathForRow(i); DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) path.getLastPathComponent(); TreeNodeAdapter adapter = (TreeNodeAdapter) treeNode.getUserObject(); adapter.setProvenance(!visualizzati); }/*from w w w . j ava 2s . co m*/ visualizzati = !visualizzati; albero.updateUI(); }
From source file:it.unibas.spicygui.controllo.tree.ActionViewAllSkolemFunctors.java
public void actionPerformed(ActionEvent e) { for (int i = 0; i < albero.getRowCount(); i++) { TreePath path = albero.getPathForRow(i); DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) path.getLastPathComponent(); TreeNodeAdapter adapter = (TreeNodeAdapter) treeNode.getUserObject(); adapter.setSkolem(!visualizzati); }//from ww w .j a va2 s . co m visualizzati = !visualizzati; albero.updateUI(); }
From source file:it.unibas.spicygui.controllo.tree.ActionViewOID.java
public void actionPerformed(ActionEvent e) { for (int i = 0; i < albero.getRowCount(); i++) { TreePath path = albero.getPathForRow(i); DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) path.getLastPathComponent(); TreeNodeAdapter adapter = (TreeNodeAdapter) treeNode.getUserObject(); adapter.setOids(!visualizzati);// w ww .jav a 2s . co m } visualizzati = !visualizzati; albero.updateUI(); }
From source file:MyData.java
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { if (value instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; Object userObject = node.getUserObject(); if (userObject instanceof Main) { MyData question = (MyData) userObject; prepareQuestionRenderer(question, selected); return checkBoxRenderer; }/*from w w w . ja v a2 s .com*/ } return super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); }