Questions tagged [jtree]

Java Swing component that displays a set of hierarchical data as an outline.

JTree is a class in the javax.swing package. It is a Swing component that displays a set of hierarchical data as a tree outline. Like most Swing components, it has a model, is highly configurable through the use of renderers, and fires events that can be handled.

Resources

1222 questions
8
votes
1 answer

Jtable as a Jtree Node

I know you can create a table and add a JTree as a column. But what I want to do is the complete opposite. Check the image and tell me if this is possible. Thanks! UPDATE: By using MKorbel's code and by randomizing the number of columns with the…
Adel Boutros
  • 10,205
  • 7
  • 55
  • 89
8
votes
2 answers

Change name of node in JTree

I am trying to change the name of a node in my JTree. I use the following code to do so: /** * Change the name of the currently selected node * @param newName Name to change the node too */ public void changeNodeName(String…
user489041
  • 27,916
  • 55
  • 135
  • 204
8
votes
3 answers

Getting a node in JTree

Simple question. I have a TreePath to a node in my JTree. How can I convert this TreePath to the DefaultMutableTreeNode the TreePath points too?
user489041
  • 27,916
  • 55
  • 135
  • 204
8
votes
1 answer

Is there a way to have expander icons for multiple roots in a JTree?

I have a JTree with multiple "roots" (Of course, I actually have an invisible real root with multiple children). The nodes expand and collapse on double click, but there's no visual indication that you can do this as there is no expander icon. This…
Draemon
  • 33,955
  • 16
  • 77
  • 104
8
votes
1 answer

Tree in scala swing

I want to use a tree in my Scala swing application, but the component isn't available in the API. Does a wrapper of JTree exists ? If not, do you have any advice for making it ? Thanks
Mr_Qqn
  • 1,578
  • 2
  • 13
  • 17
8
votes
3 answers

store state/expanded nodes of a jtree for restoring state

I am working with JTree. I would like to know what is best the way to know which nodes are expanded in a JTree so as to save its state (i.e. save all expanded paths). So that if I call model.reload() the Jtree would not stay collapsed, but I will be…
Cratylus
  • 52,998
  • 69
  • 209
  • 339
8
votes
1 answer

Is there a better way to test JTree node expanded or not?

I want to find a method like isNodeExpanded() to check if a given JTree node is expanded or not, but I can not find it. I know I can do this by tracking the node expansion with the TreeExpansionListener. Is there a better way?
waiting
  • 145
  • 1
  • 6
8
votes
1 answer

How to: JTable with collapsible JTree in first column and data in the other columns?

I am somewhat lost at this point: I try to create a JTable that is able to hold some kind of a Tree (JTree?) datastructure in the first column followed by data based on the tree Node in the other columns as illustrated in the following image: That…
Ulathar
  • 309
  • 3
  • 13
8
votes
6 answers

Speed up expand/collapse all nodes of a JTree

I have a JTree with about 100000 nodes or more. Now I want to expand the whole tree. To do so I use the solution I found here. My problem is that expanding such a large tree takes like 60 seconds or more, which is not very convenient. Does anyone…
hagt
  • 81
  • 1
  • 2
8
votes
1 answer

TreeCellRenderer: how to set background color?

I've written a custom TreeCellRenderer in order to change a components appearance. Everything works fine, except that setBackground has no effect. The code is definitely executed as the foreground color always changes correctly. Since selected items…
Pedro
  • 4,100
  • 10
  • 58
  • 96
8
votes
1 answer

How to add checkbox to JTree node to manage multiselection?

I want to build JTree which has nodes that contain check box + icon + data and tree selection algorithm.
Maxim Shoustin
  • 77,483
  • 27
  • 203
  • 225
8
votes
3 answers

How do I clear a JTree model?(Removing all nodes)

So this is a method of mine that is called everytime a new node is added.I need the model cleared everytime.The DefaultListModel has a .clear() method.The DefaultTreeModel does not.Help? public void fillUserList(){ List
Adrian Stamin
  • 687
  • 2
  • 8
  • 21
8
votes
4 answers

Expanding specific JTree path

I have a problem with expanding JTree nodes. I start when use selects a node everything but the path to the selected node and the selected node itself to be collapsed. I've tried using tree.collapsePath(new…
Ivo
  • 1,228
  • 1
  • 15
  • 33
8
votes
1 answer

changing how Nimbus LaF handles JTree node highlighting

I have been working to transition a Java application from WindowsLookAndFeel to Nimbus, largely successfully, despite Nimbus foibles. My users overall like the Nimbus LaF but didn't like some details, some of which I changed by consulting previous…
user1359010
  • 243
  • 3
  • 11
7
votes
2 answers

Put JTable in the JTree

in connection with thread Jtable as a Jtree Node I put JTable to JTree, but JTree View isn't rendered correctly on start_up, how can I setPreferredSize for JTable, because PreferredScrollableViewportSize shrinked JTable with rendering TableHeader +…
mKorbel
  • 109,525
  • 20
  • 134
  • 319
1 2
3
81 82