jtree

manipulate jtree node via references seems not working (swing)

喜夏-厌秋 提交于 2019-12-11 09:57:05
问题 I have the following problem (this is related to my post blink a tree node): I have a custom cell renderer. In some part of my code I create a new DefaultMutableTreeNode and store it in a list public static List<DefaultMutableTreeNode> nodes = new ArrayList<DefaultMutableTreeNode>() //in some time DefaultMutableTreeNode aNode = new DefaultMutableTreeNode("SomeValue"); nodes.add(node); In my cell renderer I do: public Component getTreeCellRendererComponent(JTree tree, Object value, boolean

Swing: listeners execution order on custom component

风格不统一 提交于 2019-12-11 06:49:58
问题 My custom component is composed of three JTree s inside a JPanel . Only one JTree should be selected at a time, so I've added a TreeSelectionListener to each of them that calls clearSelection on the previously selected JTree . I'd like to add other TreeSelectionListener s to the JTree s being sure that the selection- handling listeners always get executed first. I'd prefer not to put everything in one single TreeSelectionListener . What should I do? Thanks in advance! 回答1: Probably you could

Is there a fast way to expand many paths in a JTree?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 04:35:29
问题 I have a large JTree and I need to expand thousands of nodes all at once. Right now, that is taking a long time. I think it's because it's firing notifications and doing all the work for every one. Is there some way to tell it to expand all the nodes in a batch so it only has to update things once afterwards? Or some other way to make expanding lots of nodes in a batch faster? 回答1: Have you tried disabling the tree's event listeners? That way it won't fire off events every time you modify the

Using JTable for a JTree cell editor

怎甘沉沦 提交于 2019-12-11 04:07:30
问题 I would like to use a JTable for editing a JTree, I extended DefaultTreeCellEditor and implemented isCellEditable getTreeCellEditorComponent, in getTreeCellEditorComponent I return a JTable. Everything works up to this point when a node is edited swing displays the JTable filled with the objects content however when editing is complete, valueForPathChanged of DefaultTreeModel never gets called. If I use a text field for editing which is the default everything works fine. 回答1: JTextField has a

JTree isn't showing handles when it first loads up

柔情痞子 提交于 2019-12-11 03:17:49
问题 So for a project I'm working on, I need the file tree from a file manager that displays all of the directories and files from a system. I found a full working file manager called FileManager.Java which can be seen on this page: https://codereview.stackexchange.com/questions/4446/file-browser-gui However, as I said, I only need the tree part of this. I have already achieved this, and took the FileManager.java code and broke it down to what I believed necessary. That code is here: import java

JTree, always display all nodes in “edit mode”

孤者浪人 提交于 2019-12-11 02:59:27
问题 I'm displaying a tree of custom objects, and I've got custom custom CellTreeEditor and CellTreeRenderer set. Now what I really want is to always display all objects as in "edit mode". Right now I have the CellTreeRenderer.getTreeCellRendererComponent() and CellTreeEditor.getTreeCellEditorComponent() implemented almost identically. This kind of works, but I still have to click a node to focus it before I can do any editing. Is there any more sensible way of doing this, perhaps like saying no

Edit JTree's node with a textfield

早过忘川 提交于 2019-12-11 02:20:18
问题 I have a JTree cho has a renderer like that: public class BrowserNodeRenderer extends DefaultTreeCellRenderer { private JLabel label; private JPanel panel; private JLabel iconLabel; private JTextField textField; public BrowserNodeRenderer() { this.panel = new JPanel(); final BorderLayout layout = new BorderLayout(); this.panel.setLayout(layout); this.iconLabel = new JLabel(); this.label = new JLabel(); this.label.setOpaque(true); //Unbold text final Font f = this.label.getFont(); this.label

Unexpected value returned in edit - JTree

痴心易碎 提交于 2019-12-11 01:41:43
问题 In the code below there is an example JTree that has two JToggleButtons on each row and a JLabel all contained in a Holder (subclass of JPanel) . A leaf on this JTree might look like the following. And when one of the JToggleButtons are clicked, the clicked toggle button should change color. However, the output is very much different, as seen below. Why is this occurring and how can I fix the problem? Note: This return value can be found in public component getTreeCellEditorComponent(...)

JTree node's changable tooltip

天大地大妈咪最大 提交于 2019-12-10 21:17:23
问题 I have a JTree populated with some (custom) nodes. I have a class that's subclass of DefaultTreeCellRenderer and using that "MyTreeCellRenderer" i can set tooltips for each node in my tree. It works fine: JTree is populated, cell renderer is set, all added nodes do have tooltips. Problem is that i don't know how to change tooltip for certain node in already populated tree... How to do that? Is there any way to "recreate" cell renderer for just one node in JTree? 回答1: I did it! Instead of

Add rollover to JTree handles

烈酒焚心 提交于 2019-12-10 16:47:58
问题 I am trying to make a custom rollover effect on the Collapsed Icon for a JTree. However, I am unsure how to target an individual handle instead of all the handles. If you run the code below, you will see that when you hover over any handle, node, or leaf of the JTree all the collapsed handles will change to the rollover. This is not desired. So how can I change just a single handle when I am hovering over that handle, and preferably not when hovering over the node next to it? import java.awt.