Module swing.tree.component.main
Class JTreeExtensions
java.lang.Object
io.github.astrapi69.swing.tree.extension.JTreeExtensions
The class
JTreeExtensions
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Expand all nodes recursivestatic void
expandNodes
(@NonNull JTree tree) Expand all nodes but non-recursivestatic <T extends DefaultMutableTreeNode>
Optional<T>getSelectedDefaultMutableTreeNode
(@NonNull MouseEvent mouseEvent, @NonNull JTree tree) Gets the selected tree node asDefaultMutableTreeNode
objectstatic <T extends DefaultMutableTreeNode>
Optional<T>getSelectedDefaultMutableTreeNode
(@NonNull JTree tree, int x, int y) Gets the selected tree node asDefaultMutableTreeNode
objectstatic <T extends DefaultMutableTreeNode>
Optional<T>getSelectedDefaultMutableTreeNode
(@NonNull JTree tree, @NonNull Point point) Gets the selected tree node asDefaultMutableTreeNode
object from the givenPoint
objectstatic <T extends DefaultMutableTreeNode>
Optional<T>getSelectedTreeNode
(@NonNull JTree tree) Gets the selected tree node asDefaultMutableTreeNode
objectstatic <T> Optional<T>
getSelectedUserObject
(@NonNull MouseEvent mouseEvent, @NonNull JTree tree) Gets the selected user object from the givenJTree
objectstatic <T> Optional<T>
getSelectedUserObject
(@NonNull JTree tree) Gets the selected user object from the givenJTree
objectgetTreeNodes
(@NonNull TreeNode treeNode) static TreePath
getTreePath
(TreeNode treeNode)
-
Constructor Details
-
JTreeExtensions
public JTreeExtensions()
-
-
Method Details
-
getSelectedDefaultMutableTreeNode
public static <T extends DefaultMutableTreeNode> Optional<T> getSelectedDefaultMutableTreeNode(@NonNull @NonNull MouseEvent mouseEvent, @NonNull @NonNull JTree tree) Gets the selected tree node asDefaultMutableTreeNode
object- Type Parameters:
T
- the generic type- Parameters:
mouseEvent
- the mouse eventtree
- the tree- Returns:
- the selected tree node
-
getSelectedDefaultMutableTreeNode
public static <T extends DefaultMutableTreeNode> Optional<T> getSelectedDefaultMutableTreeNode(@NonNull @NonNull JTree tree, @NonNull @NonNull Point point) Gets the selected tree node asDefaultMutableTreeNode
object from the givenPoint
object- Type Parameters:
T
- the generic type- Parameters:
tree
- the treepoint
- the point- Returns:
- the selected tree node
-
getSelectedDefaultMutableTreeNode
public static <T extends DefaultMutableTreeNode> Optional<T> getSelectedDefaultMutableTreeNode(@NonNull @NonNull JTree tree, int x, int y) Gets the selected tree node asDefaultMutableTreeNode
object- Type Parameters:
T
- the generic type- Parameters:
tree
- the treex
- the horizontal x positiony
- the vertical y position- Returns:
- the selected tree node
-
expandAll
public static void expandAll(@NonNull @NonNull JTree tree, @NonNull @NonNull TreePath path, boolean expand) Expand all nodes recursive- Parameters:
tree
- the treepath
- the pathexpand
- the flag to expand or collapse
-
expandNodes
Expand all nodes but non-recursive- Parameters:
tree
- the tree
-
getSelectedUserObject
public static <T> Optional<T> getSelectedUserObject(@NonNull @NonNull MouseEvent mouseEvent, @NonNull @NonNull JTree tree) Gets the selected user object from the givenJTree
object- Type Parameters:
T
- the generic type- Parameters:
mouseEvent
- the mouse eventtree
- the tree- Returns:
- the selected user object from the given
JTree
object
-
getSelectedUserObject
Gets the selected user object from the givenJTree
object- Type Parameters:
T
- the generic type- Parameters:
tree
- the tree- Returns:
- the selected user object from the given
JTree
object
-
getSelectedTreeNode
public static <T extends DefaultMutableTreeNode> Optional<T> getSelectedTreeNode(@NonNull @NonNull JTree tree) Gets the selected tree node asDefaultMutableTreeNode
object- Type Parameters:
T
- the generic type- Parameters:
tree
- the tree- Returns:
- the selected user object from the given
JTree
object
-
getTreeNodes
-
getTreePath
-