java.lang.Object
io.github.astrapi69.swing.tree.extension.JTreeExtensions

public class JTreeExtensions extends Object
The class JTreeExtensions.
  • 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 as DefaultMutableTreeNode object
      Type Parameters:
      T - the generic type
      Parameters:
      mouseEvent - the mouse event
      tree - 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 as DefaultMutableTreeNode object from the given Point object
      Type Parameters:
      T - the generic type
      Parameters:
      tree - the tree
      point - 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 as DefaultMutableTreeNode object
      Type Parameters:
      T - the generic type
      Parameters:
      tree - the tree
      x - the horizontal x position
      y - 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 tree
      path - the path
      expand - the flag to expand or collapse
    • expandNodes

      public static void expandNodes(@NonNull @NonNull JTree tree)
      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 given JTree object
      Type Parameters:
      T - the generic type
      Parameters:
      mouseEvent - the mouse event
      tree - the tree
      Returns:
      the selected user object from the given JTree object
    • getSelectedUserObject

      public static <T> Optional<T> getSelectedUserObject(@NonNull @NonNull JTree tree)
      Gets the selected user object from the given JTree 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 as DefaultMutableTreeNode object
      Type Parameters:
      T - the generic type
      Parameters:
      tree - the tree
      Returns:
      the selected user object from the given JTree object
    • getTreeNodes

      public static List<Object> getTreeNodes(@NonNull @NonNull TreeNode treeNode)
      Creates a List object with all parent and the given TreeNode object in the parent child order
      Parameters:
      treeNode - the tree node
      Returns:
      the List object with all parent and the given TreeNode object in the parent child order
    • getTreePath

      public static TreePath getTreePath(TreeNode treeNode)
      Creates a TreePath object from the given TreeNode object
      Parameters:
      treeNode - the tree node
      Returns:
      the TreePath object from the given TreeNode object