Questions tagged [defaultmutabletreenode]

DefaultMutableTreeNode is the base class used by Java to display content in a Swing based JTree.

27 questions
2
votes
2 answers

Filter jtree - keeping all nodes and children of nodes that match criteria

I have a JTree of DefaultMutableTreeNodes and I would like to filter them. When I do a filter, I want to keep any node that matches my criteria or has children that match my criteria. Here i included the code for your reference. import…
Tamil
  • 1,193
  • 9
  • 24
2
votes
1 answer

Java remove focusPainted on DefaultMutableTreenNode in JTree

Is it possible to remove the dots border for DefaultMutableTreenNode in JTree? For JButton I use: JButton btn; btn.setFocusPainted(false); But I cannot find an equivalent for DefaultMutableTreenNode.
Fry
  • 6,235
  • 8
  • 54
  • 93
1
vote
1 answer

How would one convert a JSONObject into a DefaultMutableTreeNode in java?

I want to create a way to convert a JSONObject like this: "master root" : { "folder 1" : { "folder 2" : { "example data" : "some more example values", "example data" : "some more examples" }, …
1
vote
1 answer

JTree changes lineStyle when changing node's name

TLDR: Updating the nodes of a JTree changes the lineStyle (pictures below) and I don't know why this happens and how to prevent it from happening as my code doesn't update any porperties of the CellRenderer at the point where these changes…
Samaranth
  • 385
  • 3
  • 16
1
vote
3 answers

Hardcoding values in Java

Currently I'm trying to Hardcode some values for a family tree application in Java. Just need some ideas on how to go about it, not sure how to proceed. I have also included the constructor classes: public class TreeImpl { private…
mandok
  • 17
  • 1
  • 6
1
vote
1 answer

xml to jtree parsing in java

I have a following xml, with multiple levels( level 1, level 2, level 3). All the level 1 will go into the tab like showed in the picture.
user1631306
  • 4,350
  • 8
  • 39
  • 74
1
vote
1 answer

DefaultMutableTreeNode value set to be default when use it to Spark mapToPair

I have a question that type DefaultMutableTreeNode variable's value turns to default once use it in Spark mapToPair() function. Here is my code: public class CA implements Serializable{ private final JavaRDD input; private final…
1
vote
1 answer

JTree node editing path comparison always true

I've been working on a file server program for a while, and thus far I've been able to avoid posting something here for help. But I cannot find anything on my problem and I am very confused. I've added a popup menu with the option to create new top…
1
vote
1 answer

How to create a JTree ExpansionListener

I am having trouble creating a TreeExpansionListener. I thought it could be as easy as a TreeSelectionListener. Unfortunately I cannot find the correct interface. Here is my listener: private TreeExpansionListener createExpansionListener() { …
Nina
  • 99
  • 12
1
vote
1 answer

JTree, setUserObject(), toString()

What I'm trying to do is pretty simple, but running into some issues. I have a class and I`m overriding toString() with some value. public class AClass { @Override public String toString() { int rand = 5 + (int) (Math.random() * 25); return…
San Mor
  • 133
  • 2
  • 12
1
vote
2 answers

JTree disable highlight effect on certain nodes

I have a Jtree and I need to remove the highlight effect on certain node. So, now I have this for alla nodes and I would like have this on certain node: How can I achieve this ? Thanks
Fry
  • 6,235
  • 8
  • 54
  • 93
0
votes
1 answer

I already have a checkbox in a Java Swing TreeNode. But how do I make it checkable?

Note: I am NOT asking how to put a checkbox in a JTree - previously, a confused moderator thought this is what I was asking. I already have the checkbox in the tree. I am asking what class or method controls the checkability of the checkbox... In…
john smith
  • 619
  • 1
  • 9
  • 15
0
votes
0 answers

"AWT-EventQueue-0" java.lang.StackOverflowError - While trying to create JTree folder structure

I'm trying to build a JTree folder structure from a output. Here is the approach. I call a system get list of folders loop through list of folders and create a list create a folder structure from the list This is working fine when the number of…
0
votes
2 answers

Add same DefaultMutableTreeNode to 2 different DefaultMutableTreeNode

I have a DefaultMutableTreeNode("birds") which has n number of children. Now I want to add this node to 2 different parents DefaultMutableTreeNode("animals") & DefaultMutableTreeNodes("animals2"). But as the add or insert method of…
mayur2j
  • 141
  • 2
  • 13
0
votes
0 answers

Java Swing > Calling specific powershell script by selecting DefaultMutableTreeNode from Jtree model

I'm having my first time with java Swing and I wondering if can I add values for each DefaultMutableTreeNode and refer to them by selecting specific node? e.g. Calling specific powershell script by selecting node from Jtree model (1 node = 1…
Archie
  • 3
  • 6
1
2