java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
io.github.astrapi69.swing.base.BasePanel<T>
io.github.astrapi69.swing.tree.panel.JTreePanel<T>
Type Parameters:
T - the generic type of the model object
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
GenericBaseTreeNodePanel, GenericTreeNodePanel, JTreeWithContentPanel, PreferencesPanel

public abstract class JTreePanel<T> extends io.github.astrapi69.swing.base.BasePanel<T>
The abstract class JTreePanel provides a JTree that is already embedded in a JScrollPane. Additionally it provides factory methods that can be overwritten to provide specific behavior.
See Also:
  • Field Details

  • Constructor Details

    • JTreePanel

      public JTreePanel()
      Instantiates a new JTreePanel object.
    • JTreePanel

      public JTreePanel(io.github.astrapi69.model.api.IModel<T> model)
      Instantiates a new new JTreePanel object.
      Parameters:
      model - the model
  • Method Details

    • newPreferredSize

      protected Dimension newPreferredSize(int width, int height)
      Factory method for creating the new Dimension. This method is invoked in the constructor from the derived classes and can be overridden so users can provide their own version of a Dimension
      Parameters:
      width - the width
      height - the height
      Returns:
      the new Dimension
    • newTree

      protected JTree newTree()
      New tree.
      Returns:
      the j tree
    • newTreeModel

      protected abstract TreeModel newTreeModel(io.github.astrapi69.model.api.IModel<T> model)
      Abstract factory callback method that have to be overwritten to provide the specific TreeModel for the JTree
      Parameters:
      model - the model
      Returns:
      the tree model
    • newTreeScrollPane

      protected JScrollPane newTreeScrollPane()
      Factory method for creating the new JScrollPane. This method is invoked in the constructor from the derived classes and can be overridden so users can provide their own version of a JScrollPane
      Returns:
      the new JScrollPane
    • onTreeDoubleLeftClick

      protected void onTreeDoubleLeftClick(MouseEvent mouseEvent)
      The callback method on double left click.
      Parameters:
      mouseEvent - the mouse event
    • onTreeDoubleMiddleClick

      protected void onTreeDoubleMiddleClick(MouseEvent mouseEvent)
      The callback method on double middle click.
      Parameters:
      mouseEvent - the mouse event
    • onTreeDoubleRightClick

      protected void onTreeDoubleRightClick(MouseEvent mouseEvent)
      The callback method on double right click.
      Parameters:
      mouseEvent - the mouse event
    • onInitializeComponents

      protected void onInitializeComponents()
      Overrides:
      onInitializeComponents in class io.github.astrapi69.swing.base.BasePanel<T>
    • onInitializeLayout

      protected void onInitializeLayout()
      Overrides:
      onInitializeLayout in class io.github.astrapi69.swing.base.BasePanel<T>
    • onTreeSingleLeftClick

      protected void onTreeSingleLeftClick(MouseEvent mouseEvent)
      The callback method on single left click.
      Parameters:
      mouseEvent - the mouse event
    • onTreeSingleMiddleClick

      protected void onTreeSingleMiddleClick(MouseEvent mouseEvent)
      The callback method on single middle click.
      Parameters:
      mouseEvent - the mouse event
    • onTreeSingleRightClick

      protected void onTreeSingleRightClick(MouseEvent mouseEvent)
      The callback method on single right click.
      Parameters:
      mouseEvent - the mouse event
    • onAddNewChildTreeNode

      protected void onAddNewChildTreeNode(MouseEvent mouseEvent)
      The callback method on add a new child tree node
      Parameters:
      mouseEvent - the mouse event
    • onCopySelectedTreeNode

      protected void onCopySelectedTreeNode(MouseEvent mouseEvent)
      The callback method on copy an existing tree node
      Parameters:
      mouseEvent - the mouse event
    • onEditSelectedTreeNode

      protected void onEditSelectedTreeNode(MouseEvent mouseEvent)
      The callback method on editing the selected tree node
      Parameters:
      mouseEvent - the mouse event
    • onExpandSelectedTreeNode

      protected void onExpandSelectedTreeNode(MouseEvent mouseEvent)
      The callback method on expand the selected tree node
      Parameters:
      mouseEvent - the mouse event
    • onCollapseSelectedTreeNode

      protected void onCollapseSelectedTreeNode(MouseEvent mouseEvent)
      The callback method on collapse the selected tree node
      Parameters:
      mouseEvent - the mouse event
    • onDeleteSelectedTreeNode

      protected void onDeleteSelectedTreeNode(MouseEvent mouseEvent)
      The callback method on delete the selected tree node
      Parameters:
      mouseEvent - the mouse event
    • getSelectedTreeNode

      protected DefaultMutableTreeNode getSelectedTreeNode()
      Gets the selected tree node
      Returns:
      the selected tree node