public void actionPerformed(ActionEvent evt) { if ("expand-all".equals(getName())) { expandAll(); } else if ("collapse-all".equals(getName())) { collapseAll(); } } }
@Override public void actionPerformed(ActionEvent evt) { if ("expand-all".equals(getName())) { expandAll(); } else if ("collapse-all".equals(getName())) { collapseAll(); } } }
@Override public void actionPerformed(ActionEvent evt) { if ("expand-all".equals(getName())) { expandAll(); } else if ("collapse-all".equals(getName())) { collapseAll(); } } }
@Override public void actionPerformed(ActionEvent evt) { if ("expand-all".equals(getName())) { expandAll(); } else if ("collapse-all".equals(getName())) { collapseAll(); } } }
@Override public void actionPerformed(ActionEvent evt) { if ("expand-all".equals(getName())) { expandAll(); } else if ("collapse-all".equals(getName())) { collapseAll(); } } }
public void addPropertyPanel(PropertyPane panel) { if (panel != null) { if (!panels.contains(panel)) { DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel().getRoot(); MultiTreeNode node = new MultiTreeNode(panel); root.add(node); model.reload(); tree.expandAll(); panels.add(panel); if (panels.size() == 1) { setSelectedPropertyPanel(panel); } } } }
JXTree tree = new JXTree(); tree.expandAll(); IconValue iv = new IconValue() { Icon icon = XTestUtils.loadDefaultIcon("green-orb.png"); @Override public Icon getIcon(Object value) { return value.toString().contains("s") ? icon : null; } }; StringValue converter = new MappedValue(StringValues.TO_STRING, iv); WrappingProvider provider = new WrappingProvider(IconValues.NONE, converter); // hacking around missing api ... LabelProvider wrappee = (LabelProvider) provider.getWrappee(); wrappee.getRendererComponent(null).setHorizontalTextPosition(JLabel.LEADING); TreeCellRenderer r = new DefaultTreeRenderer(provider); tree.setCellRenderer(r);
tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.expandAll();
final JXTree tree = new JXTree(); tree.setEditable(true); tree.expandAll(); TreeSelectionListener l = new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { final TreePath path = e.getNewLeadSelectionPath(); if (path != null) { SwingUtilities.invokeLater(new Runnable() { public void run() { tree.startEditingAtPath(path); } }); } } }; tree.addTreeSelectionListener(l);
final JXTree tree = new JXTree(); tree.expandAll(); final Action delegate = tree.getActionMap().get("selectNext"); Action action = new AbstractAction("navigateNonLeaf") { @Override public void actionPerformed(ActionEvent e) { boolean searching = true; while (searching) { TreePath old = tree.getLeadSelectionPath(); delegate.actionPerformed(e); TreePath path = tree.getLeadSelectionPath(); // nothing happened, back off if (areSame(old, path)) break; Object last = path.getLastPathComponent(); if (!tree.getModel().isLeaf(last)) { searching = false; } } } // TBD: implement "end of tree" private boolean areSame(TreePath old, TreePath path) { return path.equals(old); } }; tree.getActionMap().put("selectNext", action);