jtree

JTree with checkboxes

﹥>﹥吖頭↗ 提交于 2019-12-18 02:45:47
问题 I need to add checkboxes to a JTree. A custom TreeCellRenderer/TreeCellEditor seems like the right approach. So far I used the CheckBoxNodeRenderer approach in this webpage. It works OK except for two things: there's additional whitespace above + below the checkbox; I'd like to keep it the same as a regular JTree. I would like to distinguish between clicking on the checkbox itself (which should attempt to toggle the checkbox) and clicking on the text associated with the checkbox (which should

Drag and Drop nodes in JTree

久未见 提交于 2019-12-17 17:44:08
问题 I am having difficulty creating a JTree that allows the nodes to be reorganized by dragging and dropping them in the JTree. This seems like it should be relatively simple. I have looked at examples online, but I can not seem to implement it in my own code. For example, this provided by sun allows for dragging between different components into the tree, but not from within the tree itself. And I have also found this that allows you to drag text into the JTree, but not within the tree. import

Customizing Tree.collapsedIcon for a single JTree

倖福魔咒の 提交于 2019-12-17 07:53:13
问题 I know that you can change the Tree.collapsedIcon for a all JTrees in an application using Swing using the UImanager . For example: UIManager.put("Tree.collapsedIcon",closedcabinet); I would like the flexibility of changing the Tree.collapsedIcon for individual JTrees in the same application with the end result being that the Tree.collpasedIcon could appear differently for different trees in the same application. I know how to customize individual icons using a custom renderer. For example, I

Put JTable in the JTree

走远了吗. 提交于 2019-12-17 05:11:45
问题 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 + one Row , one Row remain hidden, but after expanding Node(s) TreeRenderer change and repaint the setPreferredSize to the expected Dimension import java.awt.*; import javax.swing.*; import javax.swing.table.DefaultTableModel; import javax.swing

Why isn't my JTree updating when the TreeModel adds new nodes?

南楼画角 提交于 2019-12-14 03:48:49
问题 I am using a DefaultTreeModel populated with an override of DefaultMutableTreeNode which supports optionally changing the display string of a node in a tree. As shown in the code below, in my form I populate the tree with new nodes by creating them in a separate class and then passing them in via a wrapper class for my main data type. The procedure there is to create a new overridden DefaultMutableTreeNode , add children to it (each AccessPoint is represented by a node with several child

How to display a specific attribute name and value beside a node in JTree?

房东的猫 提交于 2019-12-14 03:46:26
问题 I want to display the name and values of an attribute beside the node name in JTree . Can anyone tell me how to do that? Here is the code I use to display the JTree : import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.Event.*; import java.io.*; import javax.swing.tree.*; import org.xml.sax.*; import org.xml.sax.helpers.*; import org.apache.xerces.parsers.*; public class XMLTreeView { private SAXTreeBuilder saxTree = null; private static String file = ""; public

JCheckBox in all nodes of a JTree

匆匆过客 提交于 2019-12-14 02:57:11
问题 I am trying to make: A JTree where ALL nodes have the possibility of a JCheckBox. After having selected the different checkboxes I would like to be able to extract strings stating the node path to the different checked nodes. The leader node must be able to show if a child node has been selected. I have included a small SSCCE import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultMutableTreeNode; import java.awt.Color;

Java tree with columns

筅森魡賤 提交于 2019-12-14 01:51:00
问题 I have a task to create java tree, with three columns: Sport name, Count of sports which are in sport category, and last update. Something similar is dispayed on image bellow: As you can see, there are 4 kinds of sports: Water, Ball, Skying, Dancing. When I expand skying, there are 3 sports of its kind. But how to make columns. I can make JTree with nodes and stuff, but how to add columns? 回答1: Here is a good example for using a Tree with multiple columns. It looks like this: I would however

How to limit the display of a Searched Node in a JTree to itself and its parents (other nodes will be excluded in the display)?

非 Y 不嫁゛ 提交于 2019-12-13 21:57:57
问题 I want to display the searched node and its parents only. I wanted to exclude the unrelated nodes. My code only does search and display but it does not filter out the other nodes. They are still in the display. What approach can be done to do this? You can get what I mean by going the Eclipse's Run Configurations' Search function. It only displays what is searched and it's "parents". Thank you so much for your input . I am trapped here for days . =( Here is my code: import java.awt

Get multiple root directories on JTree to select the leaf - Swing

五迷三道 提交于 2019-12-13 17:25:06
问题 I have been using JTree to get the multiple root directories of the system, using the example FileTreeModel.java to achieve it. And also trying to get the selected leaf (path) but it throws cast error, please give me some directions on this, have posted the code so far have tried. Thanks. import java.io.File; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTree; import javax.swing.SwingUtilities; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing