Class ComponentStyleDelegate<C extends JComponent>

java.lang.Object
swingtree.style.ComponentStyleDelegate<C>
Type Parameters:
C - The type of JComponent this ComponentStyleDelegate is for.

public final class ComponentStyleDelegate<C extends JComponent> extends Object
A ComponentStyleDelegate is a delegate for a JComponent and its StyleConf configuration used to apply further specify the style of said JComponent. Instances of this will be exposed to you via the UIForAnySwing.withStyle(Styler) method, where you can specify a lambda that takes a ComponentStyleDelegate and returns a transformed StyleConf object, as well as inside of StyleSheet extensions where you can declare similar styling lambdas for StyleTraits, which are styling rules...
  • Method Details

    • component

      public C component()
      Returns the JComponent this ComponentStyleDelegate is defining a StyleConf for. This is useful if you want to make the styling of a component based on its state, like for example determining the background color of a JCheckBox based on whether it is selected or not...
      Returns:
      The JComponent this ComponentStyleDelegate is for.
    • parent

      public Optional<Container> parent()
      Exposes the parent Container of the JComponent delegated by this ComponentStyleDelegate through an Optional in case the parent is null. You may use this to make your styling dependent on the properties of the parent container.
      Returns:
      An optional parent Container of the JComponent this ComponentStyleDelegate is for.
    • peek

      public ComponentStyleDelegate<C> peek(Peeker<C> peeker)
      Use this to peek at the JComponent of this ComponentStyleDelegate to perform some style-related component specific actions on it which are otherwise not found in the ComponentStyleDelegate API.
      Parameters:
      peeker - A Peeker that takes the JComponent of this ComponentStyleDelegate
      Returns:
      This ComponentStyleDelegate instance.
    • applyIf

      public ComponentStyleDelegate<C> applyIf(boolean condition, Styler<C> styler)
      Allows you to apply styles based on a condition. So if the first argument, the condition, is true, then it causes the supplied Styler to update the style, if however the condition is false, then the styler will simply be ignored and the style will not be updated.
      Here a simple usage example:
      
             UI.panel().withStyle( it -> it
                .border(3, Color.BLACK)
                .borderRadius(24)
                .applyIf(it.component().isEnabled(), it2 -> it2
                    .borderColor(Color.LIGHT_GRAY)
                    .backgroundColor(Color.CYAN)
                )
                .margin(3)
                .padding(4)
             );
         
      This is conceptually similar to UIForAnything.applyIf(boolean, Consumer) with the difference that it is based on a Styler instead of a consumer, as the style API is based on immutable types whose updated results must be returned by the conditional scope.
      Parameters:
      condition - The condition determining if the provided styler should be executed.
      styler - A supplier for
      Returns:
      This instance if the condition is false, or the supplied styler threw an exception, a new style delegate updated according to the styler.
    • margin

      public ComponentStyleDelegate<C> margin(double top, double right, double bottom, double left)
      Creates a new StyleConf with the provided top, right, left and bottom margin distances. It determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      top - The top padding distance in pixels.
      right - The right padding distance in pixels.
      bottom - The bottom padding distance in pixels.
      left - The left padding distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided padding distances.
    • margin

      public ComponentStyleDelegate<C> margin(double margin)
      Creates a new StyleConf with the provided margin distance for all sides of the component. The margin determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      margin - The margin distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided margin distance.
    • marginTop

      public ComponentStyleDelegate<C> marginTop(double margin)
      Creates a new StyleConf with the provided margin distance for the top side of the component. The margin determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      margin - The margin distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided margin distance.
    • marginRight

      public ComponentStyleDelegate<C> marginRight(double margin)
      Creates a new StyleConf with the provided margin distance for the right side of the component. The margin determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      margin - The margin distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided margin distance.
    • marginBottom

      public ComponentStyleDelegate<C> marginBottom(double margin)
      Creates a new StyleConf with the provided margin distance for the bottom side of the component. The margin determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      margin - The margin distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided margin distance.
    • marginLeft

      public ComponentStyleDelegate<C> marginLeft(double margin)
      Creates a new StyleConf with the provided margin distance for the left side of the component. The margin determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      margin - The margin distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided margin distance.
    • marginVertical

      public ComponentStyleDelegate<C> marginVertical(double margin)
      Creates a new StyleConf with the provided margin distance for the top and bottom sides of the component. The margin determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      margin - The margin distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided margin distance.
    • marginHorizontal

      public ComponentStyleDelegate<C> marginHorizontal(double margin)
      Creates a new StyleConf with the provided margin distance for the left and right sides of the component. The margin determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      margin - The margin distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided margin distance.
    • padding

      public ComponentStyleDelegate<C> padding(double top, double right, double bottom, double left)
      Creates a new StyleConf with the provided top, right, left and bottom pad distances. It determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      top - The top padding distance in pixels.
      right - The right padding distance in pixels.
      bottom - The bottom padding distance in pixels.
      left - The left padding distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided padding distances.
    • padding

      public ComponentStyleDelegate<C> padding(double padding)
      Creates a new StyleConf with the provided padding distance for all sides of the component. It determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      padding - The padding distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided padding distance.
    • paddingTop

      public ComponentStyleDelegate<C> paddingTop(double padding)
      Creates a new StyleConf with the provided padding distance for the top side of the component. The padding determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      padding - The padding distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided padding distance.
    • paddingRight

      public ComponentStyleDelegate<C> paddingRight(double padding)
      Creates a new StyleConf with the provided padding distance for the right side of the component. The padding determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. of the inner border, background region and shadow frame (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      padding - The padding distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided padding distance.
    • paddingBottom

      public ComponentStyleDelegate<C> paddingBottom(double padding)
      Creates a new StyleConf with the provided padding distance for the bottom side of the component. The padding determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      padding - The padding distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided padding distance.
    • paddingLeft

      public ComponentStyleDelegate<C> paddingLeft(double padding)
      Creates a new StyleConf with the provided padding distance for the left side of the component. The padding determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      padding - The padding distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided padding distance.
    • paddingVertical

      public ComponentStyleDelegate<C> paddingVertical(double padding)
      Creates a new StyleConf with the provided padding distance for the top and bottom sides of the component. The padding determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      padding - The padding distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided padding distance.
    • paddingHorizontal

      public ComponentStyleDelegate<C> paddingHorizontal(double padding)
      Creates a new StyleConf with the provided padding distance for the left and right sides of the component. The padding determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. (see borderWidth(double), backgroundColor(Color), shadowColor(Color)).
      Parameters:
      padding - The padding distance in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided padding distance.
    • border

      public ComponentStyleDelegate<C> border(double width, Color color)
      Returns a new StyleConf with the provided border width and border color. The border will be rendered with an inset space based on the margin defined by the StyleConf.
      Parameters:
      width - The border width in pixels.
      color - The border color.
      Returns:
      A new ComponentStyleDelegate with the provided border width and border color.
    • border

      public ComponentStyleDelegate<C> border(double width, Color top, Color right, Color bottom, Color left)
      Returns a new StyleConf with the provided border width and border colors. The border will be rendered with an inset space based on the margin defined by the StyleConf. You may configure the border colors for each side of the component individually.
      Parameters:
      width - The border width in pixels.
      top - The color for the top part of the border.
      right - The color for the right part of the border.
      bottom - The color for the bottom part of the border.
      left - The color for the left part of the border.
      Returns:
      A new ComponentStyleDelegate with the provided border width and border colors.
    • border

      public ComponentStyleDelegate<C> border(double top, double right, double bottom, double left, Color color)
      Returns a new StyleConf with the provided border widths and border color. The border will be rendered with an inset space based on the margin defined by the StyleConf.
      Parameters:
      top - The border width in pixels for the top side of the component.
      right - The border width in pixels for the right side of the component.
      bottom - The border width in pixels for the bottom side of the component.
      left - The border width in pixels for the left side of the component.
      color - The border color.
      Returns:
      A new ComponentStyleDelegate with the provided border widths and border color.
    • border

      public ComponentStyleDelegate<C> border(double width, String colorString)
      Returns a new StyleConf with the provided border width and border color in the form of a string. The string can be either a hex color string, a color name or a color constant from the system properties (See UIFactoryMethods.color(String) for more information on the supported color formats). The border will be rendered with an inset space based on the padding defined by the StyleConf.
      Parameters:
      width - The border width in pixels.
      colorString - The border color.
      Returns:
      A new ComponentStyleDelegate with the provided border width and border color.
    • border

      public ComponentStyleDelegate<C> border(double width, String top, String right, String bottom, String left)
      Returns a new StyleConf with the provided border width and border colors in the form of strings. The strings can be either hex color strings, color names or color constants from the system properties. The border will be rendered with an inset space based on the padding defined by the StyleConf.
      Parameters:
      width - The border width in pixels.
      top - The color for the top part of the border.
      right - The color for the right part of the border.
      bottom - The color for the bottom part of the border.
      left - The color for the left part of the border.
      Returns:
      A new ComponentStyleDelegate with the provided border width and border colors.
    • borderWidth

      public ComponentStyleDelegate<C> borderWidth(double width)
      Returns a new StyleConf with the provided border width.

      Note that in order for the border to be visible you also have to specify it's color, which you can do through borderColor(Color) or borderColor(String). You may also specify different colors for each side of the border through borderColors(Color, Color, Color, Color) or borderColors(String, String, String, String).

      Parameters:
      width - The border width in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided border width.
    • borderColors

      public ComponentStyleDelegate<C> borderColors(Color top, Color right, Color bottom, Color left)
      Returns a new StyleConf with the provided border colors, which are stored in the order of top, right, bottom, left. Note that a component border will be rendered with an inset space based on the padding defined by the StyleConf.

      Instead of null, the UI.Color.UNDEFINED constant is used to indicate that a border color is not set.

      Parameters:
      top - The color for the top part of the border.
      right - The color for the right part of the border.
      bottom - The color for the bottom part of the border.
      left - The color for the left part of the border.
      Returns:
      A new ComponentStyleDelegate with the provided border colors.
    • borderColors

      public ComponentStyleDelegate<C> borderColors(String top, String right, String bottom, String left)
      Returns a new StyleConf with the provided border colors in the form of strings. The strings can be either hex color strings, color names or color constants from the system properties (See UIFactoryMethods.color(String) for more information on the supported color formats). The border will be rendered with an inset space based on the padding defined by the StyleConf.
      Parameters:
      top - The color for the top part of the border.
      right - The color for the right part of the border.
      bottom - The color for the bottom part of the border.
      left - The color for the left part of the border.
      Returns:
      A new ComponentStyleDelegate with the provided border colors.
    • borderWidthAt

      public ComponentStyleDelegate<C> borderWidthAt(UI.Edge edge, double width)
      Returns a new StyleConf with the provided border width for the specified edge.

      Note that in order for the border to be visible you also have to specify it's color, which you can do through borderColor(Color) or borderColor(String).

      Parameters:
      edge - The edge to set the border width for.
      width - The border width in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided border width for the specified edge.
    • borderAt

      public ComponentStyleDelegate<C> borderAt(UI.Edge edge, double width, Color color)
      Returns a new StyleConf with the provided width and color used to define the border for the specified edge of the component. The border will be rendered with an inset space based on the padding defined by the StyleConf.
      Parameters:
      edge - The edge to set the border width and color for, you may use UI.Edge.EVERY to set the same width and color for all edges.
      width - The border width in pixels.
      color - The border color.
      Returns:
      A new ComponentStyleDelegate with the provided border width and color for the specified edge.
    • borderAt

      public ComponentStyleDelegate<C> borderAt(UI.Edge edge, double width, String colorString)
      Returns a new StyleConf with the provided width and color string used to define the border for the specified edge of the component. The border will be rendered with an inset space based on the padding defined by the StyleConf.

      The color is specified as a string, which can be either a hex color string, a color name or a color constant from the system properties (See UIFactoryMethods.color(String) for more information on the supported color formats).

      Parameters:
      edge - The edge to set the border width and color for, you may use UI.Edge.EVERY to set the same width and color for all edges.
      width - The border width in pixels.
      colorString - The border color.
      Returns:
      A new ComponentStyleDelegate with the provided border width and color for the specified edge.
    • borderWidths

      public ComponentStyleDelegate<C> borderWidths(double top, double right, double bottom, double left)
      Returns a new StyleConf with the provided top, right, bottom and left border widths.

      The border widths are specified in the following order: top, right, bottom, left.

      Example:

      
            UI.panel().withStyle( it -> it.borderWidths(1, 2, 3, 4) )
        

      Note that in order for the border to be visible you also have to specify it's color, which you can do through borderColor(Color) or borderColor(String).

      Parameters:
      top - The top border width in pixels.
      right - The right border width in pixels.
      bottom - The bottom border width in pixels.
      left - The left border width in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided top, right, bottom and left border widths.
      See Also:
    • borderWidths

      public ComponentStyleDelegate<C> borderWidths(double topBottom, double leftRight)
      Returns a new StyleConf with the provided top/bottom and left/right border widths.

      Example:

      
            UI.panel().withStyle( it -> it.borderWidths(1, 2) )
        

      Note that in order for the border to be visible you also have to specify it's color, which you can do through borderColor(Color) or borderColor(String).

      Parameters:
      topBottom - The top and bottom border width in pixels.
      leftRight - The left and right border width in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided top/bottom and left/right border widths.
      See Also:
    • borderColor

      public ComponentStyleDelegate<C> borderColor(Color color)
      Returns a new StyleConf with the provided border color. The border will be rendered with an inset space based on the padding defined by the StyleConf.
      Parameters:
      color - The border color.
      Returns:
      A new ComponentStyleDelegate with the provided border color.
    • borderColor

      public ComponentStyleDelegate<C> borderColor(String colorString)
      Returns an updated StyleConf with the provided border color in the form of a string. The string can be either a hex color string, a color name or a color constant from the system properties. The border will be rendered with an inset space based on the padding defined by the StyleConf.
      Parameters:
      colorString - The border color.
      Returns:
      A new ComponentStyleDelegate with the provided border color.
    • borderRadius

      public ComponentStyleDelegate<C> borderRadius(double radius)
      Returns a new StyleConf with the provided border radius set for all 4 corners of the target component. This will override both the arc width and arc height of each corner. The border will be rendered with an inset space based on the padding defined by this StyleConf.
      Parameters:
      radius - The border radius in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided border radius.
    • borderRadius

      public ComponentStyleDelegate<C> borderRadius(double arcWidth, double arcHeight)
      Returns a new StyleConf with the provided border arc width and arc height set for all 4 corners of the target component. Note that the border will be rendered with an inset space based on the padding defined by this StyleConf.
      Parameters:
      arcWidth - The border arc width in pixels.
      arcHeight - The border arc height in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided border arc width and arc height.
    • borderRadiusAt

      public ComponentStyleDelegate<C> borderRadiusAt(UI.Corner corner, double arcWidth, double arcHeight)
      Returns a new StyleConf with the provided border arc width and arc height for the specified corner. Note that the border will be rendered with an inset space based on the padding defined by this StyleConf.
      Parameters:
      corner - The corner to apply the border radius to.
      arcWidth - The border arc width in pixels.
      arcHeight - The border arc height in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided border arc width and arc height for the specified corner.
    • borderRadiusAt

      public ComponentStyleDelegate<C> borderRadiusAt(UI.Corner corner, double radius)
      Returns a new StyleConf with the provided border radius for the specified corner. This will override both the arc width and arc height of the border. Note that the border will be rendered with an inset space based on the padding defined by this StyleConf.
      Parameters:
      corner - The corner to apply the border radius to.
      radius - The border radius in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided border radius for the specified corner.
    • icon

      public ComponentStyleDelegate<C> icon(ImageIcon icon)
      Returns a new StyleConf with the provided ImageIcon as the icon for the current component (see component()). Note that this will only produce a result for components that actually support icons. Like for example all the various AbstractButton subclasses, JLabel and JIcon.
      Parameters:
      icon - The icon.
      Returns:
      A new ComponentStyleDelegate with the provided icon.
    • icon

      Returns a new StyleConf with the provided ImageIcon as the icon for the current component (see component()) and the provided fit mode determining how the icon should be fitted to the component. Note that this will only work for components that support icons. Like for example all the various AbstractButton subclasses, JLabel and JIcon.
      Parameters:
      icon - The icon in the form of an ImageIcon.
      fit - The fit mode for the icon (mostly intended for SvgIcon).
      Returns:
      A new ComponentStyleDelegate with the provided icon.
    • icon

      Returns a new StyleConf with the provided IconDeclaration as the source for the icon of the current component (see component()). Note that this will only have an effect for components that support icons. Like for example all the various AbstractButton subclasses, JLabel and JIcon.
      Parameters:
      icon - The icon declaration, which will be resolved to an ImageIcon.
      Returns:
      A new ComponentStyleDelegate with the provided icon.
    • icon

      Returns a new StyleConf with the provided IconDeclaration as the source for the icon of the current component (see component()) and the provided fit mode determining how the icon should be fitted to the component. Note that this will only have an effect for components that support icons. Like for example all the various AbstractButton subclasses, JLabel and JIcon.
      Parameters:
      icon - The icon declaration, which will be resolved to an ImageIcon.
      fit - The fit mode for the icon (mostly intended for SvgIcon).
      Returns:
      A new ComponentStyleDelegate with the provided icon.
    • foundationColor

      public ComponentStyleDelegate<C> foundationColor(Color color)
      Returns a new StyleConf with the provided background foundation color. The foundation color covers the UI.ComponentArea.EXTERIOR, which starts at the outer bounds of the component and the beginning of the border. So the space spanned by the margins of the component including the additional exterior space exposed by the border radius.
      Parameters:
      color - The background color.
      Returns:
      A new ComponentStyleDelegate with the provided background color.
    • foundationColor

      public ComponentStyleDelegate<C> foundationColor(String colorString)
      Returns a new StyleConf with the provided background foundation color in the form of a string. The string can be either a hex color string, a color name or a color constant from the system properties. The foundation color covers the UI.ComponentArea.EXTERIOR, which starts at the outer bounds of the component and the beginning of the border. So the space spanned by the margins of the component including the additional exterior space exposed by the border radius.
      Parameters:
      colorString - The background color.
      Returns:
      A new ComponentStyleDelegate with the provided background color.
    • foundationColor

      public ComponentStyleDelegate<C> foundationColor(double r, double g, double b)
      Returns a new StyleConf with the provided background foundation color defined by the supplied red, green and blue color channels in the form of doubles expected to be in the range of 0.0 to 1.0. The foundation color covers the UI.ComponentArea.EXTERIOR, which starts at the outer bounds of the component and the beginning of the border. So the space spanned by the margins of the component including the additional exterior space exposed by the border radius.
      Parameters:
      r - The red component of the background color in the range of 0.0 to 1.0.
      g - The green component of the background color in the range of 0.0 to 1.0.
      b - The blue component of the background color in the range of 0.0 to 1.0.
      Returns:
      A new ComponentStyleDelegate with the provided background color.
    • foundationColor

      public ComponentStyleDelegate<C> foundationColor(double r, double g, double b, double a)
      Returns a new StyleConf with the provided background foundation color defined by the supplied red, green, blue and alpha color channels in the form of doubles expected to be in the range of 0.0 to 1.0. The foundation color covers the UI.ComponentArea.EXTERIOR, which starts at the outer bounds of the component and the beginning of the border. So the space spanned by the margins of the component including the additional exterior space exposed by the border radius.
      Parameters:
      r - The red component of the background color in the range of 0.0 to 1.0.
      g - The green component of the background color in the range of 0.0 to 1.0.
      b - The blue component of the background color in the range of 0.0 to 1.0.
      a - The alpha component of the background color in the range of 0.0 to 1.0.
      Returns:
      A new ComponentStyleDelegate with the provided background color.
    • backgroundColor

      public ComponentStyleDelegate<C> backgroundColor(Color color)
      Returns a new StyleConf with the provided inner Background color. The background color covers the UI.ComponentArea.INTERIOR, which, when going inwards, starts at the end of the component's border area (UI.ComponentArea.BORDER), (which is defined by UI.ComponentBoundary.BORDER_TO_INTERIOR) and then completely fills the component's inner bounds (UI.ComponentArea.INTERIOR), including both the space spanned by the padding and the content area.
      Parameters:
      color - The inner background color.
      Returns:
      A new ComponentStyleDelegate with the provided inner background color.
    • backgroundColor

      public ComponentStyleDelegate<C> backgroundColor(double r, double g, double b)
      Returns a new StyleConf with the provided inner Background color defined by the supplied red, green and blue color channels in the form of doubles expected to be in the range of 0.0 to 1.0. The background color covers the UI.ComponentArea.INTERIOR, which, when going inwards, starts at the end of the component's border area (UI.ComponentArea.BORDER), (which is defined by UI.ComponentBoundary.BORDER_TO_INTERIOR) and then completely fills the component's inner bounds (UI.ComponentArea.INTERIOR), including both the space spanned by the padding and the content area.
      Parameters:
      r - The red component of the inner background color in the range of 0.0 to 1.0.
      g - The green component of the inner background color in the range of 0.0 to 1.0.
      b - The blue component of the inner background color in the range of 0.0 to 1.0.
      Returns:
      A new ComponentStyleDelegate with the provided inner background color.
    • backgroundColor

      public ComponentStyleDelegate<C> backgroundColor(double r, double g, double b, double a)
      Returns a new StyleConf with the provided inner Background color defined by the supplied red, green, blue and alpha color channels in the form of doubles expected to be in the range of 0.0 to 1.0. The background color covers the UI.ComponentArea.INTERIOR, which, when going inwards, starts at the end of the component's border area (UI.ComponentArea.BORDER), (which is defined by UI.ComponentBoundary.BORDER_TO_INTERIOR) and then completely fills the component's inner bounds (UI.ComponentArea.INTERIOR), including both the space spanned by the padding and the content area.
      Parameters:
      r - The red component of the inner background color in the range of 0.0 to 1.0.
      g - The green component of the inner background color in the range of 0.0 to 1.0.
      b - The blue component of the inner background color in the range of 0.0 to 1.0.
      a - The alpha component of the inner background color in the range of 0.0 to 1.0.
      Returns:
      A new ComponentStyleDelegate with the provided inner background color.
    • backgroundColor

      public ComponentStyleDelegate<C> backgroundColor(String colorString)
      Returns a new StyleConf with the provided inner Background color in the form of a string. The string can be either a hex color string, a color name or a color constant from the system properties. The background color covers the UI.ComponentArea.INTERIOR, which, when going inwards, starts at the end of the component's border area (UI.ComponentArea.BORDER), (which is defined by UI.ComponentBoundary.BORDER_TO_INTERIOR) and then completely fills the component's inner bounds (UI.ComponentArea.INTERIOR), including both the space spanned by the padding and the content area.
      Parameters:
      colorString - The inner background color.
      Returns:
      A new ComponentStyleDelegate with the provided inner background color.
    • painter

      public ComponentStyleDelegate<C> painter(UI.Layer layer, Painter painter)
      Returns a new StyleConf with the provided custom Painter, which will be called using the Graphics2D of the current component. You may use this to render a custom background for the component.

      Note that your custom painter will yield the best performance if they are value based in the sense that they have Object.hashCode() and Object.equals(Object) implementation which are based on the data that the painter uses to render the component. This is because it allows SwingTree to cache the rendering of the painters and avoid unnecessary repaints.
      If you do not want to create a custom class just for painting but instead just want to pass an immutable cache key to a painter, then consider using the Painter.of(Object, Painter) factory method to create a painter that has the with Object.hashCode() and Object.equals(Object) implemented based on the provided cache key.
      Parameters:
      layer - The layer on which the painter should do its work. It is an enum instance which gives the painter a particular rank in the painting order. So the UI.Layer.BACKGROUND will be painted first, followed by the UI.Layer.CONTENT and so on...
      The following layers are available:
      painter - A custom painter, which receives the Graphics2D instance of the current component.
      Returns:
      A new ComponentStyleDelegate with the provided background renderer.
    • painter

      public ComponentStyleDelegate<C> painter(UI.Layer layer, UI.ComponentArea clipArea, Painter painter)
      Returns a new StyleConf with the provided custom Painter, which will be called using the Graphics2D of the current component. You may use this to render a custom background for the component on the specified UI.Layer and UI.ComponentArea.

      Note that your custom painter will yield the best performance if they are value based in the sense that they have Object.hashCode() and Object.equals(Object) implementation which are based on the data that the painter uses to render the component. This is because it allows SwingTree to cache the rendering of the painters and avoid unnecessary repaints.
      If you do not want to create a custom class just for painting but instead just want to pass an immutable cache key to a painter, then consider using the Painter.of(Object, Painter) factory method to create a painter that has the with Object.hashCode() and Object.equals(Object) implemented based on the provided cache key.
      Parameters:
      layer - The layer on which the painter should do its work. It is an enum instance which gives the painter a particular rank in the painting order. So the UI.Layer.BACKGROUND will be painted first, followed by the UI.Layer.CONTENT and so on...
      The following layers are available:
      clipArea - The area to which the painting should be confined. Paint operations outside of this area will be clipped away. The following areas are available:
      painter - A custom painter, which receives the Graphics2D instance of the current component.
      Returns:
      A new ComponentStyleDelegate with the provided background renderer.
    • painter

      public ComponentStyleDelegate<C> painter(UI.Layer layer, String painterName, Painter painter)
      Returns a new StyleConf with the provided named Painter, which will be called using the Graphics2D instance of the current component. You may use this to render custom styles for the component...
      The name can be used to override Painter instances with that same name or use a unique name to ensure that you style is not overridden by another style. This allows you to attach an arbitrary number of custom painters to a component.

      Note that your custom painter will yield the best performance if they are value based in the sense that they have Object.hashCode() and Object.equals(Object) implementation which are based on the data that the painter uses to render the component. This is because it allows SwingTree to cache the rendering of the painters and avoid unnecessary repaints.
      If you do not want to create a custom class just for painting but instead just want to pass an immutable cache key to a painter, then consider using the Painter.of(Object, Painter) factory method to create a painter that has the with Object.hashCode() and Object.equals(Object) implemented based on the provided cache key.
      Parameters:
      layer - The layer on which the painter should do its work. It is an enum instance which gives the painter a particular rank in the painting order. So the UI.Layer.BACKGROUND will be painted first, followed by the UI.Layer.CONTENT and so on...
      The following layers are available:
      painterName - The name of the painter.
      painter - The custom painter lambda to which the Graphics2D instance of the current component will be passed.
      Returns:
      A new ComponentStyleDelegate with the provided background renderer.
    • painter

      public ComponentStyleDelegate<C> painter(UI.Layer layer, UI.ComponentArea clipArea, String painterName, Painter painter)
      Returns a new StyleConf with the provided named Painter, which will be called using the Graphics2D instance of the current component. You may use this to render custom styles for the component...
      The name can be used to override Painter instances with that same name or use a unique name to ensure that you style is not overridden by another style. This allows you to attach an arbitrary number of custom painters to a component.

      Note that your custom painter will yield the best performance if they are value based in the sense that they have Object.hashCode() and Object.equals(Object) implementation which are based on the data that the painter uses to render the component. This is because it allows SwingTree to cache the rendering of the painters and avoid unnecessary repaints.
      If you do not want to create a custom class just for painting but instead just want to pass an immutable cache key to a painter, then consider using the Painter.of(Object, Painter) factory method to create a painter that has the with Object.hashCode() and Object.equals(Object) implemented based on the provided cache key.
      Parameters:
      layer - The layer on which the painter should do its work. It is an enum instance which gives the painter a particular rank in the painting order. So the UI.Layer.BACKGROUND will be painted first, followed by the UI.Layer.CONTENT and so on...
      The following layers are available:
      clipArea - The area to which the painting should be confined. Paint operations outside of this area will be clipped away. The following areas are available:
      painterName - The name of the painter.
      painter - The custom painter lambda to which the Graphics2D instance of the current component will be passed.
      Returns:
      A new ComponentStyleDelegate with the provided background renderer.
    • foregroundColor

      public ComponentStyleDelegate<C> foregroundColor(Color color)
      Returns a new StyleConf with the provided foreground color.
      Parameters:
      color - The foreground color.
      Returns:
      A new ComponentStyleDelegate with the provided foreground color.
    • foregroundColor

      public ComponentStyleDelegate<C> foregroundColor(String colorString)
      Returns a new StyleConf with the provided foreground color in the form of a string. The string can be either a hex color string, a color name or a color constant from the system properties.
      Parameters:
      colorString - The foreground color.
      Returns:
      A new ComponentStyleDelegate with the provided foreground color.
    • shadowHorizontalOffset

      public ComponentStyleDelegate<C> shadowHorizontalOffset(double offset)
      Returns a new StyleConf with the provided horizontal shadow offset applied to all shadow configs. The shadow will be rendered with an inset space based on the padding defined by this StyleConf. Note that in order to see the shadow, you may also need to call shadowSpreadRadius(double), shadowBlurRadius(double) and shadowColor(Color).
      Note that this property will not only be applied to the default shadow, but also any other named shadow that you may have defined using shadow(String, Configurator).
      Parameters:
      offset - The shadow offset in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided horizontal shadow offset.
    • shadowVerticalOffset

      public ComponentStyleDelegate<C> shadowVerticalOffset(double offset)
      Returns a new StyleConf with the provided vertical shadow offset applied to all shadow configs. The shadow will be rendered with an inset space based on the padding defined by this StyleConf. Note that in order to see the shadow, you may also need to call shadowSpreadRadius(double), shadowBlurRadius(double) and shadowColor(Color).
      Note that this property will not only be applied to the default shadow, but also any other named shadow that you may have defined using shadow(String, Configurator).
      Parameters:
      offset - The shadow offset in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided vertical shadow offset.
    • shadowOffset

      public ComponentStyleDelegate<C> shadowOffset(double horizontalOffset, double verticalOffset)
      Returns a new StyleConf with the provided shadow offset applied to all shadow configs. The shadow will be rendered with an inset space based on the padding defined by this StyleConf. Note that in order to see the shadow, you may also need to call shadowSpreadRadius(double), shadowBlurRadius(double) and shadowColor(Color).
      Note that this property will not only be applied to the default shadow, but also any other named shadow that you may have defined using shadow(String, Configurator).
      Parameters:
      horizontalOffset - The horizontal shadow offset in pixels.
      verticalOffset - The vertical shadow offset in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided shadow offset.
    • shadowOffset

      public ComponentStyleDelegate<C> shadowOffset(double horizontalAndVerticalOffset)
      Returns a new StyleConf with the provided horizontal and vertical shadow offset. The shadow will be rendered with an inset space based on the padding defined by this StyleConf. Note that in order to see the shadow, you may also need to call shadowSpreadRadius(double), shadowBlurRadius(double) and shadowColor(Color).
      Note that this property will not only be applied to the default shadow, but also any other named shadow that you may have defined using shadow(String, Configurator).
      Parameters:
      horizontalAndVerticalOffset - The horizontal and vertical shadow offset in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided shadow offset.
    • shadowBlurRadius

      public ComponentStyleDelegate<C> shadowBlurRadius(double radius)
      Returns a new StyleConf with the provided shadow blur radius applied to all shadow configs. The shadow will be rendered with an inset space based on the padding defined by this StyleConf. Note that in order to see the shadow, you may also need to call shadowSpreadRadius(double) and shadowColor(Color).
      Note that this property will not only be applied to the default shadow, but also any other named shadow that you may have defined using shadow(String, Configurator).
      Parameters:
      radius - The shadow blur radius in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided shadow blur radius.
    • shadowSpreadRadius

      public ComponentStyleDelegate<C> shadowSpreadRadius(double radius)
      Returns a new StyleConf with the provided shadow spread radius applied to all shadow configs. The shadow will be rendered with an inset space based on the padding defined by this StyleConf. Note that in order to see the shadow, you may also need to call shadowBlurRadius(double) and shadowColor(Color).
      Note that this property will not only be applied to the default shadow, but also any other named shadow that you may have defined using shadow(String, Configurator).
      Parameters:
      radius - The shadow spread radius in pixels.
      Returns:
      A new ComponentStyleDelegate with the provided shadow spread radius.
    • shadowColor

      public ComponentStyleDelegate<C> shadowColor(Color color)
      Returns a new StyleConf with the provided shadow color applied to the default shadow. Note that in order to see the shadow, you may also need to call shadowBlurRadius(double) and shadowSpreadRadius(double).
      The shadow will be rendered on the UI.Layer.CONTENT layer, if you want it to be rendered on a different layer, you may want to take a look at shadow(UI.Layer, String, Configurator).

      Note that this property will not only be applied to the default shadow, but also any other named shadow that you may have defined using shadow(String, Configurator) (and which are also rendered on the UI.Layer.CONTENT layer).
      Parameters:
      color - The shadow color.
      Returns:
      A new ComponentStyleDelegate with the provided shadow color.
    • shadowColor

      public ComponentStyleDelegate<C> shadowColor(String colorString)
      Returns a new StyleConf with the provided shadow color in the form of a string. The string can be either a hex color string, a color name or a color constant from the system properties. Note that in order to see the shadow, you may also need to call shadowBlurRadius(double) and shadowSpreadRadius(double).
      The shadow will be rendered on the UI.Layer.CONTENT layer, if you want it to be rendered on a different layer, you may want to take a look at shadow(UI.Layer, String, Configurator).

      Note that this property will not only be applied to the default shadow, but also any other named shadow that you may have defined using shadow(String, Configurator) (and which are also rendered on the UI.Layer.CONTENT layer).
      Parameters:
      colorString - The shadow color.
      Returns:
      A new ComponentStyleDelegate with the provided shadow color.
    • shadowColor

      public ComponentStyleDelegate<C> shadowColor(double r, double g, double b)
      Returns a new StyleConf with the provided shadow color defined by the supplied red, green and blue color channels in the form of doubles expected to be in the range of 0.0 to 1.0. Note that in order to see the shadow, you may also need to call shadowBlurRadius(double) and shadowSpreadRadius(double).
      The shadow will be rendered on the UI.Layer.CONTENT layer, if you want it to be rendered on a different layer, you may want to take a look at shadow(UI.Layer, String, Configurator).

      Note that this property will not only be applied to the default shadow, but also any other named shadow that you may have defined using shadow(String, Configurator) (and which are also rendered on the UI.Layer.CONTENT layer).
      Parameters:
      r - The red component of the shadow color in the range of 0.0 to 1.0.
      g - The green component of the shadow color in the range of 0.0 to 1.0.
      b - The blue component of the shadow color in the range of 0.0 to 1.0.
      Returns:
      A new ComponentStyleDelegate with the provided shadow color.
    • shadowColor

      public ComponentStyleDelegate<C> shadowColor(double r, double g, double b, double a)
      Returns a new StyleConf with the provided shadow color defined by the supplied red, green, blue and alpha color channels in the form of doubles expected to be in the range of 0.0 to 1.0. Note that in order to see the shadow, you may also need to call shadowBlurRadius(double) and shadowSpreadRadius(double).
      The shadow will be rendered on the UI.Layer.CONTENT layer, if you want it to be rendered on a different layer, you may want to take a look at shadow(UI.Layer, String, Configurator).

      Note that this property will not only be applied to the default shadow, but also any other named shadow that you may have defined using shadow(String, Configurator) (and which are also rendered on the UI.Layer.CONTENT layer).
      Parameters:
      r - The red component of the shadow color in the range of 0.0 to 1.0.
      g - The green component of the shadow color in the range of 0.0 to 1.0.
      b - The blue component of the shadow color in the range of 0.0 to 1.0.
      a - The alpha component of the shadow color in the range of 0.0 to 1.0.
      Returns:
      A new ComponentStyleDelegate with the provided shadow color.
    • shadowIsInset

      public ComponentStyleDelegate<C> shadowIsInset(boolean inwards)
      Use this to control whether your shadows should be rendered inwards or outwards.
      Note that this property will be applied to all shadow effects of all layers, including the default shadow and named shadows defined using shadow(String, Configurator).
      The default value is false.
      Parameters:
      inwards - Whether the shadow should be rendered inwards or outwards.
      Returns:
      A new ComponentStyleDelegate with the provided shadow inset flag.
    • shadow

      public ComponentStyleDelegate<C> shadow(String shadowName, Configurator<ShadowConf> styler)
      This method makes it possible to define multiple shadows for a single component on the UI.Layer.CONTENT layer, by giving the shadow config a unique name. This is useful when you want to do advanced shadow effects, such as neumorphism a.k.a. soft UI.
      Here is an example of how to use this method:
      
            UI.panel()
            .withStyle( it -> it
                .shadow("dark shading", shadow -> shadow
                    .color("#000000")
                    .horizontalOffset(5)
                    .verticalOffset(5)
                    .blurRadius(10)
                    .spreadRadius(0)
                )
                .shadow("light shading", shadow -> shadow
                    .color("#ffffff")
                    .horizontalOffset(-5)
                    .verticalOffset(-5)
                    .blurRadius(10)
                    .spreadRadius(0)
                )
        
      Note that the shadows will be rendered in alphabetical order based on their name (within a particular layer).
      Parameters:
      shadowName - The name of the shadow.
      styler - A function that takes a ShadowConf and returns a new ShadowConf.
      Returns:
      A new ComponentStyleDelegate with a named shadow defined by the provided styler lambda.
    • shadow

      public ComponentStyleDelegate<C> shadow(UI.Layer layer, String shadowName, Configurator<ShadowConf> styler)
      This method makes it possible to define multiple shadows for a single component on a custom layer, by giving the shadow config a unique name. This is useful when you want to do advanced shadow effects, such as neumorphism a.k.a. soft UI.
      Here is an example of how to use this method:
      
            UI.panel()
            .withStyle( it -> it
                .shadow(UI.Layer.CONTENT, "dark shading", shadow -> shadow
                    .color("#000000")
                    .horizontalOffset(5)
                    .verticalOffset(5)
                    .blurRadius(10)
                    .spreadRadius(0)
                )
                .shadow(UI.Layer.CONTENT, "light shading", shadow -> shadow
                    .color("#ffffff")
                    .horizontalOffset(-5)
                    .verticalOffset(-5)
                    .blurRadius(10)
                    .spreadRadius(0)
                )
        
      Note that the shadows will be rendered in alphabetical order based on their name (within a particular layer).
      Parameters:
      layer - The layer of the shadow is an enum instance which gives the shadow effect a rank in the painting order. So the UI.Layer.BACKGROUND will be painted first, followed by the UI.Layer.CONTENT and so on...
      The following layers are available:
      shadowName - The name of the shadow.
      styler - A function that takes a ShadowConf and returns a new ShadowConf.
      Returns:
      A new ComponentStyleDelegate with a named shadow defined by the provided styler lambda.
    • gradient

      public ComponentStyleDelegate<C> gradient(String shadeName, Configurator<GradientConf> styler)
      This method makes it possible to define multiple background gradient for a single component on the UI.Layer.BACKGROUND layer, by giving the gradient config a unique name. This is useful when you want to do advanced background effects, such as neumorphism a.k.a. soft UI.
      Here is an example of how to use this method:
      
          UI.panel()
          .withStyle( it -> it
            .gradient("dark shading", conf -> conf
              .colors("#000000", "#000000")
              .transition(UI.Transition.TOP_TO_BOTTOM)
            )
            .gradient("light shading", conf -> conf
              .colors("#ffffff", "#ffffff")
              .transition(UI.Transition.TOP_TO_BOTTOM))
            )
          )
       
      Note that the background shades will be rendered in alphabetical order based on the name of the shade.
      This method translates to gradient(UI.Layer, String, Configurator) but with the layer set to UI.Layer.BACKGROUND.
      Parameters:
      shadeName - The name of the background shade.
      styler - A function that takes a GradientConf and returns a new GradientConf.
      Returns:
      A new ComponentStyleDelegate with a named background shade defined by the provided styler lambda.
    • gradient

      public ComponentStyleDelegate<C> gradient(UI.Layer layer, String shadeName, Configurator<GradientConf> styler)
      This method makes it possible to define multiple background gradient for a single component on a particular layer, by giving the gradient config a unique name. This is useful when you want to do advanced background effects, such as neumorphism a.k.a. soft UI.
      Here is an example of how to use this method:
      
          UI.panel()
          .withStyle( it -> it
            .gradient(UI.Layer.BACKGROUND, "dark shading", conf -> conf
              .colors("#000000", "#000000")
              .transition(UI.Transition.TOP_TO_BOTTOM)
            )
            .gradient(UI.Layer.BACKGROUND, "light shading", conf -> conf
              .colors("#ffffff", "#ffffff")
              .transition(UI.Transition.TOP_TO_BOTTOM))
            )
          )
       
      Note that within a particular layer the gradients will be rendered in alphabetical order based on the provided name.
      Parameters:
      layer - The layer on which the gradient should be rendered.
      shadeName - The name of the background shade.
      styler - A function that takes a GradientConf and returns a new GradientConf.
      Returns:
      A new ComponentStyleDelegate with a named background shade defined by the provided styler lambda.
    • gradient

      public ComponentStyleDelegate<C> gradient(Configurator<GradientConf> styler)
      This method makes it possible to define a background shade for your components. This is useful when you want to do advanced background effects, such as neumorphism a.k.a. soft UI.
      Here is an example of how to use this method:
      
          UI.panel()
          .withStyle( it -> it
              .gradient( conf -> conf
                  .colors("#000000", "#000000")
                  .transition(UI.Transition.TOP_TO_BOTTOM)
              )
          )
       
      This method translates to gradient(UI.Layer, String, Configurator) but with the layer set to UI.Layer.BACKGROUND and the name being the "default" style name
      Parameters:
      styler - A function that takes a GradientConf and returns a new GradientConf.
      Returns:
      A new ComponentStyleDelegate with a background shade defined by the provided styler lambda.
    • gradient

      public ComponentStyleDelegate<C> gradient(UI.Layer layer, Configurator<GradientConf> styler)
      This method makes it possible to define a gradient effect on a particular layer for your components. This is useful when you want to do advanced background effects, such as neumorphism a.k.a. soft UI.
      Here is an example of how to use this method:
      
          UI.panel()
          .withStyle( it -> it
              .gradient(UI.Layer.BACKGROUND, conf -> conf
                  .colors("#000000", "#000000")
                  .transition(UI.Transition.TOP_TO_BOTTOM)
              )
          )
       
      Note that this method translates to gradient(UI.Layer, String, Configurator) but with the name being the "default" style name.
      Parameters:
      layer - The layer on which the gradient should be rendered.
      styler - A function that takes a GradientConf and returns a new GradientConf.
      Returns:
      A new ComponentStyleDelegate with a background shade defined by the provided styler lambda.
    • noise

      public ComponentStyleDelegate<C> noise(String noiseName, Configurator<NoiseConf> styler)
      This method makes it possible to define a background noise for your components. This is useful when you want to give component surfaces some naturally looking texture or special effects.

      Here is an example of how to use it:
      
          UI.panel()
          .withStyle( it -> it
              .noise("my-noise" conf -> conf
                  .scale(2, 3).rotation(45)
                  .colors(Color.BLACK, Color.WHITE)
                  .offset(64,85)
              )
          )
       
      Note that this method translates to noise(UI.Layer, String, Configurator) but with the layer set to UI.Layer.BACKGROUND.
      Parameters:
      noiseName - The name of the noise which is used to create, identify and possibly override a noise with the same name.
      styler - A function that takes a NoiseConf and returns a new NoiseConf.
      Returns:
      A new ComponentStyleDelegate with a background noise defined by the provided styler lambda.
    • noise

      public ComponentStyleDelegate<C> noise(UI.Layer layer, String noiseName, Configurator<NoiseConf> styler)
      This method makes it possible to define a background noise for your components. This is useful when you want to give component surfaces some naturally looking texture or special effects.

      Here is an example of how to use the method:
      
          UI.panel()
          .withStyle( it -> it
              .noise(UI.Layer.BACKGROUND, "my-noise" conf -> conf
                  .scale(2, 3).rotation(45)
                  .colors(Color.BLACK, Color.WHITE)
                  .offset(64,85)
              )
          )
       
      Parameters:
      layer - The layer on which the noise should be rendered.
      styler - A function that takes a NoiseConf and returns a new NoiseConf.
      Returns:
      A new ComponentStyleDelegate with a background noise defined by the provided styler lambda.
    • noise

      This method makes it possible to define a background noise for your components. This is useful when you want to give component surfaces some naturally looking texture or special effects.

      Here is an example of how to use this method:
      
          UI.panel()
          .withStyle( it -> it
              .noise( conf -> conf
                  .scale(2, 3).rotation(45)
                  .colors(Color.BLACK, Color.WHITE)
                  .offset(64,85)
              )
          )
       
      Note that this method translates to noise(UI.Layer, String, Configurator) but with the layer set to UI.Layer.BACKGROUND and the name being the "default" style name.
      Parameters:
      styler - A function that takes a NoiseConf and returns a new NoiseConf.
      Returns:
      A new ComponentStyleDelegate with a background noise defined by the provided styler lambda.
    • image

      public ComponentStyleDelegate<C> image(String imageName, Configurator<ImageConf> styler)
      This method makes it possible to define multiple background styles for a single component rendered on the UI.Layer.BACKGROUND layer, by giving the background config a unique name. This is useful when you want to do advanced backgrounds displaying multiple images on top of each other.
      Here is an example of how to use this method:
      
          UI.panel()
          .withStyle( it -> it
            .image("ground 1", image -> image
              .image(loadImageFrom("my/path/to/image1.png"))
            )
            .ground("ground 2", ground -> ground
              .color("blue")
            )
          )
       
      Note that the background images will be rendered in alphabetical order based on the name of the image.
      Parameters:
      imageName - The name of the background image.
      styler - A function that takes a ImageConf and returns a new ImageConf.
      Returns:
      A new ComponentStyleDelegate with a named background image defined by the provided styler lambda.
    • image

      public ComponentStyleDelegate<C> image(UI.Layer layer, String imageName, Configurator<ImageConf> styler)
      This method makes it possible to define multiple background styles for a single component rendered on a particular layer, by giving the background config a unique name. This is useful when you want to do advanced layer backgrounds displaying multiple images on top of each other.
      Here is an example of how to use this method:
      
          UI.panel()
          .withStyle( it -> it
            .image(UI.Layer.BACKGROUND, "ground 1", image -> image
              .image(loadImageFrom("my/path/to/image1.png"))
            )
            .ground(UI.Layer.BACKGROUND, "ground 2", ground -> ground
              .color("blue")
            )
          )
       
      Note that the background images will be rendered in alphabetical order based on the name of the image.
      Parameters:
      layer - The layer defines at which step in the rendering process the image should be rendered. The default layer is the background layer, which will be rendered first. Here a list of available layers:
      imageName - The name of the background image.
      styler - A function that takes a ImageConf and returns a new ImageConf.
      Returns:
      A new ComponentStyleDelegate with a named background image defined by the provided styler lambda.
    • image

      Allows for the rendering of a background image on your components. This is useful when you want to do advanced backgrounds displaying multiple images on top of each other.
      Here is an example of how to use this method:
      
          UI.panel()
          .withStyle( it -> it
              .image( image -> image
                  .image(loadImageFrom("my/path/to/image1.png"))
                  .color("green")
              )
          )
       
      Note that this method translates to image(UI.Layer, String, Configurator) but with the layer set to UI.Layer.BACKGROUND and the name being the "default" style name.
      Parameters:
      styler - A function that takes a ImageConf and returns a new ImageConf.
      Returns:
      A new ComponentStyleDelegate with a background image defined by the provided styler lambda.
    • image

      public ComponentStyleDelegate<C> image(UI.Layer layer, Configurator<ImageConf> styler)
      Allows for the rendering of an image on a particular component layer. This is useful when you want to do advanced layer backgrounds displaying multiple images on top of each other.
      Here is an example of how to use this method:
      
          UI.panel()
          .withStyle( it -> it
              .image(UI.Layer.CONTENT, image -> image
                  .image(loadImageFrom("my/path/to/image1.png"))
                  .color("green")
              )
          )
       
      Note that this method translates to image(UI.Layer, String, Configurator) but with the name being the "default" style name.
      Parameters:
      layer - The layer on which the image should be rendered.
      styler - A function that takes a ImageConf and returns a new ImageConf.
      Returns:
      A new ComponentStyleDelegate with a background image defined by the provided styler lambda.
    • text

      public ComponentStyleDelegate<C> text(String textName, Configurator<TextConf> styler)
      Returns an updated StyleConf with a named text style configurator for the default TextConf of the component.
      The sub-style exposed by this method adds support for text rendering to all components not just text components.
      If you only want to style the Component.getFont() property of the component, you can use componentFont(Configurator) instead.

      The first parameter is the name of the text style, which allows you to define any number of text styles for a single component by using different names.
      Two sub-styles with the same name will override each other.
      Parameters:
      styler - A configurator function that takes a TextConf and returns an updated TextConf. The configurator function is called with the default text style of the component.
      Returns:
      A new ComponentStyleDelegate with the provided text style. Each unique name creates an additional text style for the component.
      Throws:
      NullPointerException - If the provided styler or textName is null.
      See Also:
    • text

      public ComponentStyleDelegate<C> text(UI.Layer layer, String textName, Configurator<TextConf> styler)
      Returns an updated StyleConf with the provided named text style configurator for the default TextConf of the component.
      The sub-style exposed by this method adds support for text rendering to all components not just text components.
      If you only want to style the Component.getFont() property of the component, you can use componentFont(Configurator) instead.

      The first parameter is the name of the text style, which allows you to define any number of text styles for a single component by using different names.
      Two sub-styles with the same name will override each other.
      Parameters:
      layer - The layer on which the text should be rendered.
      textName - The name of the text style that you want to define. Each unique name creates an additional text style for the component.
      styler - A configurator function that takes a TextConf and returns an updated TextConf. The configurator function is called with the default text style of the component.
      Returns:
      A new ComponentStyleDelegate with the provided text style.
      Throws:
      NullPointerException - If the provided styler or textName is null.
      See Also:
    • text

      Returns an updated StyleConf with the provided text style configurator for the default TextConf of the component.
      The sub-style exposed by this method adds support for text rendering to all components not just text components.
      If you only want to style the Component.getFont() property of the component, you can use componentFont(Configurator) instead.
      Parameters:
      styler - A configurator function that takes a TextConf and returns an updated TextConf. The configurator function is called with the default text style of the component.
      Returns:
      A new ComponentStyleDelegate with the provided text style.
      Throws:
      NullPointerException - If the provided styler is null.
      See Also:
    • property

      public ComponentStyleDelegate<C> property(String key, String value)
      Allow for the specification of client properties on the styled component. This is useful when you want to store arbitrary configuration data on the component, which is usually read and used by look and feel implementations to apply custom appearance and behavior to the component.

      If you want a particular property to be removed, you can pass and empty String "" as the value.
      A null reference is not allowed as a value and will throw a NullPointerException.
      Parameters:
      key - The key of the property.
      value - The value of the property.
      Returns:
      A new ComponentStyleDelegate with the provided client property.
      Throws:
      NullPointerException - If the value is null! (Use "" to remove a property)
      See Also:
    • parentFilter

      public ComponentStyleDelegate<C> parentFilter(Configurator<FilterConf> filterStyler)
    • componentFont

      public final ComponentStyleDelegate<C> componentFont(Configurator<FontConf> fontStyler)
      Returns a new StyleConf with the provided font style applied to the font property of the component (see Component.getFont()).
      If you want to style the text of the entire component, which includes both the component font property as well as the style engine based font render (see text(String, Configurator)), you can simply call the regular font styling methods such as font(String, int), font(Font), fontFamily(String), fontSize(int), fontBold(boolean), fontItalic(boolean), fontUnderline(boolean)...
      Parameters:
      fontStyler - A function that takes a FontConf and returns a new FontConf that is exclusively applied to the font property of the component.
      Returns:
      A new ComponentStyleDelegate with the provided font style applied to the font property of the component.
    • font

      public ComponentStyleDelegate<C> font(String name, int size)
      Returns a new StyleConf with the provided font name and size.
      Note that the font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      name - The font name.
      size - The font size.
      Returns:
      A new ComponentStyleDelegate with the provided font name and size.
    • fontFamily

      public ComponentStyleDelegate<C> fontFamily(String name)
      Returns a new StyleConf with the provided font family name. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      name - The font name.
      Returns:
      A new ComponentStyleDelegate with the provided font name.
    • font

      public ComponentStyleDelegate<C> font(Font font)
      Returns a new StyleConf with the provided Font. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      font - The Font.
      Returns:
      A new ComponentStyleDelegate with the provided Font.
      Throws:
      NullPointerException - If the font is null. Use UI.Font.UNDEFINED to remove the font style.
    • fontSize

      public ComponentStyleDelegate<C> fontSize(int size)
      Returns a new StyleConf with the provided font size. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      size - The font size.
      Returns:
      A new ComponentStyleDelegate with the provided font size.
    • fontBold

      public ComponentStyleDelegate<C> fontBold(boolean bold)
      Makes the font bold or not bold depending on the value of the isBold parameter. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      bold - Whether the font should be bold or not.
      Returns:
      A new ComponentStyleDelegate with the provided font boldness.
    • fontItalic

      public ComponentStyleDelegate<C> fontItalic(boolean italic)
      Makes the font italic or not italic depending on the value of the italic parameter. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      italic - Whether the font should be italic or not.
      Returns:
      A new ComponentStyleDelegate with the provided font italicness.
    • fontStyle

      public ComponentStyleDelegate<C> fontStyle(UI.FontStyle style)
      Determines if the font should be plain, bold, italic or bold and italic based on the provided UI.FontStyle parameter, which may be UI.FontStyle.PLAIN, UI.FontStyle.BOLD, UI.FontStyle.ITALIC or UI.FontStyle.BOLD_ITALIC.
      Note that this will override any previous bold or italic settings.
      Parameters:
      style - The font style in form of a UI.FontStyle.
      Returns:
      An updated ComponentStyleDelegate with the provided font style.
    • fontUnderline

      public ComponentStyleDelegate<C> fontUnderline(boolean underline)
      Makes the font underlined or not underlined depending on the value of the underline parameter. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      underline - Whether the font should be underlined or not.
      Returns:
      A new ComponentStyleDelegate with the provided font underlinedness.
    • fontStrikeThrough

      public ComponentStyleDelegate<C> fontStrikeThrough(boolean strikeThrough)
      Makes the font struck through or not struck through depending on the value of the strikeThrough parameter. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      strikeThrough - Whether the font should be struck through or not.
      Returns:
      A new ComponentStyleDelegate with the provided font struck throughness.
    • fontColor

      public ComponentStyleDelegate<C> fontColor(Color color)
      Creates a new StyleConf where the font color is set to the provided Color. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      color - The Color.
      Returns:
      A new ComponentStyleDelegate with the provided font color.
      Throws:
      NullPointerException - If the color is null. Use UI.Color.UNDEFINED to remove the font color style.
    • fontColor

      public ComponentStyleDelegate<C> fontColor(String colorString)
      Creates a new StyleConf where the font color is set to a color parsed from the provided string. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      colorString - The Color as a string.
      Returns:
      A new ComponentStyleDelegate with the provided font color.
    • fontBackgroundColor

      public ComponentStyleDelegate<C> fontBackgroundColor(Color color)
      Creates a new StyleConf where the font background color is set to the provided Color. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      color - The Color.
      Returns:
      A new ComponentStyleDelegate with the provided font background color.
      Throws:
      NullPointerException - If the color is null. Use UI.Color.UNDEFINED to remove the font background color style.
    • fontBackgroundColor

      public ComponentStyleDelegate<C> fontBackgroundColor(String colorString)
      Creates a new StyleConf where the font color is set to a color parsed from the provided string. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      colorString - The Color as a string.
      Returns:
      A new ComponentStyleDelegate with the provided font color.
    • fontSelectionColor

      public ComponentStyleDelegate<C> fontSelectionColor(Color color)
      Creates a new StyleConf where the font selection color is set to the provided Color. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      color - The Color.
      Returns:
      A new ComponentStyleDelegate with the provided font selection color.
      Throws:
      NullPointerException - If the color is null. Use UI.Color.UNDEFINED to remove the font selection color style.
    • fontSelectionColor

      public ComponentStyleDelegate<C> fontSelectionColor(String colorString)
      Creates a new StyleConf where the font selection color is set to a color parsed from the provided string. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      colorString - The Color as a string.
      Returns:
      A new ComponentStyleDelegate with the provided font selection color.
    • fontTransform

      public ComponentStyleDelegate<C> fontTransform(@Nullable AffineTransform transform)
      The AffineTransform property of a font defines how the font is rotated, scaled, skewed or translated. This method allows you to apply a custom AffineTransform to the fonts of the component.
      Parameters:
      transform - The AffineTransform to apply to the font.
      Returns:
      A new ComponentStyleDelegate with the provided font transform.
    • fontPaint

      public ComponentStyleDelegate<C> fontPaint(@Nullable Paint paint)
      Creates an updated style config with the provided font paint applied to all font configurations of the component.
      Parameters:
      paint - The Paint to use for the foreground of the font, which translates to the TextAttribute.FOREGROUND attribute.
      Returns:
      A new ComponentStyleDelegate with the provided font paint.
    • fontBackgroundPaint

      public ComponentStyleDelegate<C> fontBackgroundPaint(@Nullable Paint paint)
      Updates this style delegate with the supplied Paint object used for the background of the font, which translates to the TextAttribute.BACKGROUND attribute.
      Parameters:
      paint - The Paint to use for the background of the font, which translates to the TextAttribute.BACKGROUND attribute.
      Returns:
      A new ComponentStyleDelegate with the provided font background paint.
    • fontWeight

      public ComponentStyleDelegate<C> fontWeight(float weight)
      Use this to define the weight of the default font of the component. The default value is 1.0 (see TextAttribute.WEIGHT_REGULAR), whereas a bold font typically has a font weight of 2.0 (see TextAttribute.WEIGHT_BOLD).

      Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).

      Note that this font style will be applied to both the component font property and the style engine based text (see text(String, Configurator)). If you only want to style the component font property, you can use componentFont(Configurator).

      Parameters:
      weight - The weight of the font.
      Returns:
      A new ComponentStyleDelegate with the provided font weight.
    • fontSpacing

      public ComponentStyleDelegate<C> fontSpacing(float spacing)
      The font spacing, which is also known as tracking, is the space between characters in a font. See TextAttribute.TRACKING for more information.
      Parameters:
      spacing - The spacing of the default font of the component, which translates to the TextAttribute.TRACKING attribute.
      Returns:
      A new ComponentStyleDelegate with the provided font spacing.
    • fontAlignment

      public ComponentStyleDelegate<C> fontAlignment(UI.HorizontalAlignment alignment)
      Use this to define the horizontal alignment of the default font of the component. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).
      Also note that not all text based components support text alignment.
      Parameters:
      alignment - The horizontal alignment of the font. See UI.HorizontalAlignment for more information.
      Returns:
      A new ComponentStyleDelegate with the provided font alignment.
      Throws:
      NullPointerException - If the alignment is null. Use UI.HorizontalAlignment.UNDEFINED to remove the font alignment style.
    • fontAlignment

      public ComponentStyleDelegate<C> fontAlignment(UI.VerticalAlignment alignment)
      Use this to define the vertical alignment of the default font of the component. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).
      Also note that not all text based components support text alignment.
      Parameters:
      alignment - The vertical alignment of the font. See UI.VerticalAlignment for more information.
      Returns:
      A new ComponentStyleDelegate with the provided font alignment. throws NullPointerException If the alignment is null. Use UI.VerticalAlignment.UNDEFINED to remove the font alignment style.
    • fontAlignment

      public ComponentStyleDelegate<C> fontAlignment(UI.Alignment alignment)
      Use this to define the horizontal and vertical alignment of the default font of the component. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (see TextConf).
      Also note that not all text based components support text alignment.
      Parameters:
      alignment - The horizontal and vertical alignment of the font. See UI.Alignment for more information.
      Returns:
      A new ComponentStyleDelegate with the provided font alignment. throws NullPointerException If the alignment is null. Use UI.Alignment.UNDEFINED to remove the font alignment style.
    • minSize

      public ComponentStyleDelegate<C> minSize(int width, int height)
      Defines the minimum Dimension for this JComponent.
      This ultimately translates to JComponent.setMinimumSize(Dimension) on the underlying component, which will be called when all the other styles are applied and rendered.
      Parameters:
      width - The minimum width.
      height - The minimum height.
      Returns:
      A new ComponentStyleDelegate with the provided minimum Dimension set to be later applied to the underlying component when the final StyleConf is applied.
    • minSize

      public ComponentStyleDelegate<C> minSize(Size size)
      Defines the minimum size for this JComponent in the form of a Size object.
      This ultimately translates to JComponent.setMinimumSize(Dimension) on the underlying component, which will be called when all the other styles are applied and rendered.
      Parameters:
      size - The minimum Size.
      Returns:
      A new ComponentStyleDelegate with the provided minimum Size set to be later applied to the underlying component when the final StyleConf is applied.
    • minWidth

      public ComponentStyleDelegate<C> minWidth(int minWidth)
      Defines the minimum width for this JComponent.
      This ultimately translates to JComponent.setMinimumSize(Dimension) on the underlying component, which will be called when all the other styles are applied and rendered.
      Parameters:
      minWidth - The minimum width.
      Returns:
      A new ComponentStyleDelegate with the provided minimum width set to be later applied to the underlying component when the final StyleConf is applied.
    • minHeight

      public ComponentStyleDelegate<C> minHeight(int minHeight)
      Defines the minimum height for this JComponent.
      This ultimately translates to JComponent.setMinimumSize(Dimension) on the underlying component, which will be called when all the other styles are applied and rendered.
      Parameters:
      minHeight - The minimum height.
      Returns:
      A new ComponentStyleDelegate with the provided minimum height set to be later applied to the underlying component when the final StyleConf is applied.
    • maxSize

      public ComponentStyleDelegate<C> maxSize(int width, int height)
      Defines the maximum Dimension for this JComponent.
      This ultimately translates to JComponent.setMaximumSize(Dimension) on the underlying component.
      The passed Dimension will be applied when all the other styles are applied and rendered.
      Parameters:
      width - The maximum width.
      height - The maximum height.
      Returns:
      A new ComponentStyleDelegate with the provided maximum Dimension set to be later applied to the underlying component when the final StyleConf is applied.
    • maxSize

      public ComponentStyleDelegate<C> maxSize(Size maxSize)
      Defines the maximum Size for this JComponent.
      This ultimately translates to JComponent.setMaximumSize(Dimension) on the underlying component.
      The passed Size will be applied when all the other styles are applied and rendered.
      Parameters:
      maxSize - The maximum Size.
      Returns:
      A new ComponentStyleDelegate with the provided maximum Size set to be later applied to the underlying component when the final StyleConf is applied.
    • maxWidth

      public ComponentStyleDelegate<C> maxWidth(int maxWidth)
      Defines the maximum width for this JComponent.
      This ultimately translates to JComponent.setMaximumSize(Dimension) on the underlying component.
      The passed width will be applied when all the other styles are applied and rendered.
      Parameters:
      maxWidth - The maximum width.
      Returns:
      A new ComponentStyleDelegate with the provided maximum width set to be later applied to the underlying component when the final StyleConf is applied.
    • maxHeight

      public ComponentStyleDelegate<C> maxHeight(int maxHeight)
      Defines the maximum height for this JComponent.
      This ultimately translates to JComponent.setMaximumSize(Dimension) on the underlying component.
      The passed height will be applied when all the other styles are applied and rendered.
      Parameters:
      maxHeight - The maximum height.
      Returns:
      A new ComponentStyleDelegate with the provided maximum height set to be later applied to the underlying component when the final StyleConf is applied.
    • prefSize

      public ComponentStyleDelegate<C> prefSize(Size preferredSize)
      Defines the preferred Size for this JComponent.
      This ultimately translates to JComponent.setPreferredSize(Dimension) on the underlying component.
      The passed Size will be applied when all the other styles are applied and rendered.
      Parameters:
      preferredSize - The preferred Size.
      Returns:
      A new ComponentStyleDelegate with the provided preferred Size set to be later applied to the underlying component when the final StyleConf is applied.
    • prefSize

      public ComponentStyleDelegate<C> prefSize(int width, int height)
      Defines the preferred Dimension for this JComponent.
      This ultimately translates to JComponent.setPreferredSize(Dimension) on the underlying component.
      The passed Dimension will be applied when all the other styles are applied and rendered.
      Parameters:
      width - The preferred width.
      height - The preferred height.
      Returns:
      A new ComponentStyleDelegate with the provided preferred Dimension set to be later applied to the underlying component when the final StyleConf is applied.
    • prefWidth

      public ComponentStyleDelegate<C> prefWidth(int preferredWidth)
      Defines the preferred width for this JComponent.
      This ultimately translates to JComponent.setPreferredSize(Dimension) on the underlying component.
      The passed width will be applied when all the other styles are applied and rendered.
      Parameters:
      preferredWidth - The preferred width.
      Returns:
      A new ComponentStyleDelegate with the provided preferred width set to be later applied to the underlying component when the final StyleConf is applied.
    • prefHeight

      public ComponentStyleDelegate<C> prefHeight(int preferredHeight)
      Defines the preferred height for this JComponent.
      This ultimately translates to JComponent.setPreferredSize(Dimension) on the underlying component.
      The passed height will be applied when all the other styles are applied and rendered.
      Parameters:
      preferredHeight - The preferred height.
      Returns:
      A new ComponentStyleDelegate with the provided preferred height set to be later applied to the underlying component when the final StyleConf is applied.
    • size

      public ComponentStyleDelegate<C> size(Size size)
      Defines the size of this JComponent.
      This ultimately translates to Component.setSize(Dimension) on the underlying component.
      Parameters:
      size - The width and height size Dimension.
      Returns:
      A new ComponentStyleDelegate with the provided Size (width and height) set to be later applied to the underlying component when the final StyleConf is applied.
    • size

      public ComponentStyleDelegate<C> size(int width, int height)
      Defines the size of this JComponent.
      This ultimately translates to Component.setSize(Dimension) on the underlying component.
      Parameters:
      width - The width.
      height - The height.
      Returns:
      A new ComponentStyleDelegate with the provided size (width and height) Dimension set to be later applied to the underlying component when the final StyleConf is applied.
    • width

      public ComponentStyleDelegate<C> width(int width)
      Defines the width of this JComponent.
      This ultimately translates to Component.setSize(Dimension) on the underlying component.
      Parameters:
      width - The width.
      Returns:
      A new ComponentStyleDelegate with the provided width set to be later applied to the underlying component when the final StyleConf is applied.
    • height

      public ComponentStyleDelegate<C> height(int height)
      Defines the height of this JComponent.
      This ultimately translates to Component.setSize(Dimension) on the underlying component.
      Parameters:
      height - The height.
      Returns:
      A new ComponentStyleDelegate with the provided height set to be later applied to the underlying component when the final StyleConf is applied.
    • cursor

      public ComponentStyleDelegate<C> cursor(UI.Cursor cursor)
      Defines the cursor type for this JComponent based on the predefined UI.Cursor values.
      If you want to specify a custom cursor implementation, use cursor(Cursor) instead.
      Parameters:
      cursor - The UI.Cursor value.
      Returns:
      A new ComponentStyleDelegate with the provided cursor type set to be later
    • cursor

      public ComponentStyleDelegate<C> cursor(Cursor cursor)
      Defines the cursor type for this JComponent based on the provided Cursor value.
      Use this method if you want to specify a custom cursor implementation, in case you merely want to pick one of the many predefined UI.Cursor values, use cursor(UI.Cursor) instead.
      Parameters:
      cursor - The Cursor value.
      Returns:
      A new ComponentStyleDelegate with the provided cursor type set to be later
    • orientation

      public ComponentStyleDelegate<C> orientation(UI.ComponentOrientation orientation)
      Determines how the component is oriented, typically with respect to the text direction and where content originates.
      This translates to Component.setComponentOrientation(ComponentOrientation) on the underlying component.

      Note that although all components support this property, it may not always have a noticeable effect on the component.
      How this property is interpreted depends heavily on the component, it's layout manager and the look and feel implementation.
      Parameters:
      orientation - The UI.ComponentOrientation, which maps 1:1 to the AWT ComponentOrientation constants.
      Returns:
      A new ComponentStyleDelegate with the provided UI.ComponentOrientation set to be later applied to the underlying component when the final StyleConf is applied.
    • layout

      public ComponentStyleDelegate<C> layout(Layout installer)
      Use this to define the layout manager for this JComponent using a Layout object.
      Checkout the factory methods in Layout for creating different types of layout managers like Layout.flow(), Layout.mig(String) or Layout.grid(int, int).
      Parameters:
      installer - The Layout to use for installing the layout.
      Returns:
      A new ComponentStyleDelegate with the provided Layout set to be later
    • layout

      public ComponentStyleDelegate<C> layout(String constraints)
      Defines the layout MigLayout constraints for this JComponent in the form of a String.
      This ultimately translates to MigLayout.setLayoutConstraints(Object) on the underlying component.

      Note that if this property is specified, the style engine will automatically install a MigLayout on the component if it does not already have one.
      Parameters:
      constraints - The layout constraints as a String.
      Returns:
      A new ComponentStyleDelegate with the provided layout constraints set to be later
    • layout

      public ComponentStyleDelegate<C> layout(String constraints, String columnConstraints)
      Defines the MigLayout based layout constraints and column layout constraints of this JComponent in the form of a String.
      This ultimately translates to MigLayout.setLayoutConstraints(Object) as well as MigLayout.setColumnConstraints(Object) on the layout manager of the underlying component.

      Note that if this property is specified, the style engine will automatically install a MigLayout on the component if it does not already have one.
      Parameters:
      constraints - The layout constraints as a String.
      columnConstraints - The column constraints as a String.
      Returns:
      A new ComponentStyleDelegate with the provided layout constraints set to be later
    • layout

      public ComponentStyleDelegate<C> layout(String constraints, String columnConstraints, String rowConstraints)
      Defines the MigLayout based layout constraints column layout constraints and row layout constraints of this JComponent in the form of a String.
      This ultimately translates to MigLayout.setLayoutConstraints(Object) as well as MigLayout.setColumnConstraints(Object) and MigLayout.setRowConstraints(Object) on the layout manager of the underlying component.

      Note that if this property is specified, the style engine will automatically install a MigLayout on the component if it does not already have one.
      Parameters:
      constraints - The layout constraints as a String.
      columnConstraints - The column constraints as a String.
      rowConstraints - The row constraints as a String.
      Returns:
      A new ComponentStyleDelegate with the provided layout constraints set to be later
    • addConstraint

      public ComponentStyleDelegate<C> addConstraint(Object constraints)
      Defines the component constraints of this component with respect to the parent component and its layout manager, in the form of a String.
      This ultimately translates to MigLayout.setComponentConstraints(Component, Object) on the layout manager of the parent component.

      Note that if this property is specified, the style engine will automatically install a MigLayout on the parent component if it does not already have one.
      Parameters:
      constraints - The component constraints as a String.
      Returns:
      A new ComponentStyleDelegate with the provided component constraints set to be later
    • layout

      public ComponentStyleDelegate<C> layout(LayoutConstraint constraintAttr)
      Defines the layout MigLayout constraints for this JComponent in the form of a LayoutConstraint (see UILayoutConstants.FILL, UILayoutConstants.FILL_X, UILayoutConstants.FILL_Y...).
      This ultimately translates to MigLayout.setLayoutConstraints(Object) on the underlying component.

      Note that if this property is specified, the style engine will automatically install a MigLayout on the component if it does not already have one.
      Parameters:
      constraintAttr - The layout constraints as a LayoutConstraint.
      Returns:
      A new ComponentStyleDelegate with the provided layout constraints set to be later
    • alignmentX

      public ComponentStyleDelegate<C> alignmentX(float percentage)
      Defines the alignment percentage alongside the X axis for a component (see JComponent.setAlignmentX(float)).
      Note that the alignment may not have an effect on all components as it depends on the layout manager of the component.
      Parameters:
      percentage - The alignment percentage in terms of a number between 0 and 1 alongside the X axis.
      Returns:
      A new ComponentStyleDelegate with the provided alignment percentage alongside the X axis set to be later
    • alignmentY

      public ComponentStyleDelegate<C> alignmentY(float percentage)
      Defines the alignment percentage alongside the Y axis for a component (see JComponent.setAlignmentY(float)).
      Note that the alignment may not have an effect on all components as it depends on the layout manager of the component.
      Parameters:
      percentage - The alignment percentage in terms of a number between 0 and 1 alongside the Y axis.
      Returns:
      A new ComponentStyleDelegate with the provided alignment percentage alongside the Y axis set to be later
    • getScale

      public float getScale()
      A convenient delegate method to UI.scale() which exposes the current UI scale factor that is used to scale the UI for high resolution displays (high dots-per-inch, or DPI). Use this scale factor when writing custom rendering code against the Graphics2D API.
      Returns:
      The current UI scale factor, which is used to scale the UI for high resolution displays (high dots-per-inch, or DPI).
    • scale

      public float scale()
      A convenient delegate method to UI.scale() which exposes the current UI scale factor that is used to scale the UI for high resolution displays (high dots-per-inch, or DPI). Use this scale factor when writing custom rendering code against the Graphics2D API.
      Returns:
      The current UI scale factor, which is used to scale the UI for high resolution displays (high dots-per-inch, or DPI).
    • scale

      public int scale(int value)
      Use this method inside custom Painter implementations (see painter(UI.Layer, swingtree.api.Painter)) to scale an int value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).
      Parameters:
      value - The int value to scale.
      Returns:
      The scaled int value.
    • scale

      public float scale(float value)
      Use this method inside custom Painter implementations (see painter(UI.Layer, swingtree.api.Painter)) to scale a float value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).
      Parameters:
      value - The float value to scale.
      Returns:
      The scaled float value.
    • scale

      public double scale(double value)
      Use this method inside custom Painter implementations (see painter(UI.Layer, Painter)) to scale a double value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).
      Parameters:
      value - The double value to scale.
      Returns:
      The scaled double value.
    • toString

      public String toString()
      Overrides:
      toString in class Object