Module java.desktop

Class MetalTreeUI

  • public class MetalTreeUI
    extends BasicTreeUI
    The metal look and feel implementation of TreeUI.

    MetalTreeUI allows for configuring how to visually render the spacing and delineation between nodes. The following hints are supported:

    Descriptions of supported hints: Angled, Horizontal, and None
    Hint Description
    Angled A line is drawn connecting the child to the parent. For handling of the root node refer to JTree.setRootVisible(boolean) and JTree.setShowsRootHandles(boolean).
    Horizontal A horizontal line is drawn dividing the children of the root node.
    None Do not draw any visual indication between nodes.

    As it is typically impractical to obtain the TreeUI from the JTree and cast to an instance of MetalTreeUI you enable this property via the client property JTree.lineStyle. For example, to switch to Horizontal style you would do: tree.putClientProperty("JTree.lineStyle", "Horizontal");

    The default is Angled.

    • Constructor Detail

      • MetalTreeUI

        public MetalTreeUI()
        Constructs the MetalTreeUI.
    • Method Detail

      • createUI

        public static ComponentUI createUI​(JComponent x)
        Constructs the MetalTreeUI.
        x - a component
        the instance of the MetalTreeUI
      • decodeLineStyle

        protected void decodeLineStyle​(Object lineStyleFlag)
        Converts between the string passed into the client property and the internal representation (currently and int)
        lineStyleFlag - a flag
      • isLocationInExpandControl

        protected boolean isLocationInExpandControl​(int row,
                                                    int rowLevel,
                                                    int mouseX,
                                                    int mouseY)
        Returns true if a point with X coordinate mouseX and Y coordinate mouseY is in expanded control.
        row - a row
        rowLevel - a row level
        mouseX - X coordinate
        mouseY - Y coordinate
        true if a point with X coordinate mouseX and Y coordinate mouseY is in expanded control.
      • paintHorizontalSeparators

        protected void paintHorizontalSeparators​(Graphics g,
                                                 JComponent c)
        Paints the horizontal separators.
        g - an instance of Graphics
        c - a component