java.lang.Object
io.github.astrapi69.swing.tree.JTreeExtensions
The class
JTreeExtensions.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidExpand all nodes recursivestatic voidexpandNodes(@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 asDefaultMutableTreeNodeobjectstatic <T extends DefaultMutableTreeNode>
Optional<T>getSelectedDefaultMutableTreeNode(@NonNull JTree tree, int x, int y) Gets the selected tree node asDefaultMutableTreeNodeobjectstatic <T extends DefaultMutableTreeNode>
Optional<T>getSelectedDefaultMutableTreeNode(@NonNull JTree tree, @NonNull Point point) Gets the selected tree node asDefaultMutableTreeNodeobject from the givenPointobjectstatic <T extends DefaultMutableTreeNode>
Optional<T>getSelectedTreeNode(@NonNull JTree tree) Gets the selected tree node asDefaultMutableTreeNodeobjectstatic <T> Optional<T>getSelectedUserObject(@NonNull MouseEvent mouseEvent, @NonNull JTree tree) Gets the selected user object from the givenJTreeobjectstatic <T> Optional<T>getSelectedUserObject(@NonNull JTree tree) Gets the selected user object from the givenJTreeobjectgetTreeNodes(@NonNull TreeNode treeNode) static TreePathgetTreePath(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 asDefaultMutableTreeNodeobject- 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 asDefaultMutableTreeNodeobject from the givenPointobject- 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 asDefaultMutableTreeNodeobject- 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 givenJTreeobject- Type Parameters:
T- the generic type- Parameters:
mouseEvent- the mouse eventtree- the tree- Returns:
- the selected user object from the given
JTreeobject
-
getSelectedUserObject
Gets the selected user object from the givenJTreeobject- Type Parameters:
T- the generic type- Parameters:
tree- the tree- Returns:
- the selected user object from the given
JTreeobject
-
getSelectedTreeNode
public static <T extends DefaultMutableTreeNode> Optional<T> getSelectedTreeNode(@NonNull @NonNull JTree tree) Gets the selected tree node asDefaultMutableTreeNodeobject- Type Parameters:
T- the generic type- Parameters:
tree- the tree- Returns:
- the selected user object from the given
JTreeobject
-
getTreeNodes
-
getTreePath
-