List of usage examples for javax.swing JTree expandRow
int expandRow
To view the source code for javax.swing JTree expandRow.
Click Source Link
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTree tree = new JTree(); for (int i = 0; i < tree.getRowCount(); i++) { tree.expandRow(i); }//from w w w . j ava2 s . c om f.add(new JScrollPane(tree)); f.pack(); f.setSize(200, 200); f.setVisible(true); }
From source file:TreeNodeVector.java
public static void main(final String args[]) { JFrame frame = new JFrame("JTreeSample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<String> v1 = new TreeNodeVector<String>("Two", new String[] { "Mercury", "Venus", "Mars" }); Vector<Object> v2 = new TreeNodeVector<Object>("Three"); v2.add(System.getProperties()); v2.add(v1);//from w w w . jav a 2 s. c o m Object rootNodes[] = { v1, v2 }; Vector<Object> rootVector = new TreeNodeVector<Object>("Root", rootNodes); JTree tree = new JTree(rootVector); frame.add(new JScrollPane(tree), BorderLayout.CENTER); tree.expandRow(1); tree.scrollRowToVisible(2); tree.revalidate(); frame.setSize(300, 300); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { JFrame f = new JFrame("Test"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTree tree = new JTree(); tree.putClientProperty("JTree.lineStyle", "Angled"); // tree.putClientProperty("JTree.lineStyle", "Horizontal"); // tree.putClientProperty("JTree.lineStyle", "None"); for (int i = 0; i < tree.getRowCount(); i++) { tree.expandRow(i); }//from www.j a v a 2s . c o m f.add(tree); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(Main.class.getSimpleName()); DefaultTreeModel model = getTreeModel(); JTree tree1 = new JTree(model); JTree tree2 = new JTree(model); frame.add(new JScrollPane(tree1), BorderLayout.WEST); frame.add(new JScrollPane(tree2), BorderLayout.EAST); frame.pack();/*from w w w. j a va 2 s . c o m*/ frame.setSize(frame.getWidth() + 50, frame.getHeight() + 140); frame.setVisible(true); Timer t = new Timer(2000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); root.add(new DefaultMutableTreeNode("A new node")); model.nodesWereInserted(root, new int[] { root.getChildCount() - 1 }); tree1.expandRow(0); tree2.expandRow(0); frame.revalidate(); } }); t.start(); }
From source file:Main.java
public static void expandAllNodes(JTree tree) { int row = 0;//from w w w .jav a 2 s .co m while (row < tree.getRowCount()) { tree.expandRow(row); ++row; } }
From source file:Main.java
/** * Stolen from http://stackoverflow.com/a/19935987/5620200 * @param tree/*from w w w . j av a 2s. co m*/ * @param startingIndex * @param rowCount */ public static void expand(JTree tree, int startingIndex, int rowCount) { for (int i = startingIndex; i < rowCount; ++i) { tree.expandRow(i); } if (tree.getRowCount() != rowCount) { expand(tree, rowCount, tree.getRowCount()); } }
From source file:Main.java
public static void expandJTree(JTree toexpand) { // replace this with a sensible implementation if it fails for (int row = 0; row < toexpand.getRowCount(); ++row) { toexpand.expandRow(row); }/*ww w . ja v a 2s .co m*/ }
From source file:ec.nbdemetra.ui.demo.ComponentsDemo.java
private static void expandAll(JTree tree) { int row = 0;/*from w ww . jav a 2 s .c o m*/ while (row < tree.getRowCount()) { tree.expandRow(row); row++; } }
From source file:it.unibas.spicygui.Utility.java
public static void expandAll(JTree tree) { int row = 0;/*from www . j a va 2s. com*/ while (row < tree.getRowCount()) { tree.expandRow(row); row++; } }
From source file:Main.java
/** * Loads the given expansion state of a JTree, making it expand in the given manner. * /* w ww . j av a2 s. c om*/ * @param tree * The JTree to be expended * @param enumeration * The expansion state for tree as Enumeration<TreePath> */ public static void loadTreeExpansionState(JTree tree, String expansionState, int row) { // if a tree is opened for the first time, its expansionState is null if (expansionState == null) { return; } StringTokenizer stok = new StringTokenizer(expansionState, ","); while (stok.hasMoreTokens()) { int token = row + Integer.parseInt(stok.nextToken()); tree.expandRow(token); } }