Class ComponentStyleDelegate<C extends JComponent>
- Type Parameters:
C- The type ofJComponentthisComponentStyleDelegateis for.
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 Summary
Modifier and TypeMethodDescriptionaddConstraint(Object constraints) Defines the component constraints of this component with respect to the parent component and its layout manager, in the form of aString.alignmentX(float percentage) Defines the alignment percentage alongside the X axis for a component (seeJComponent.setAlignmentX(float)).alignmentY(float percentage) Defines the alignment percentage alongside the Y axis for a component (seeJComponent.setAlignmentY(float)).Allows you to apply styles based on a condition.backgroundColor(double r, double g, double b) Returns a newStyleConfwith 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.backgroundColor(double r, double g, double b, double a) Returns a newStyleConfwith 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.backgroundColor(Color color) Returns a newStyleConfwith the provided inner Background color.backgroundColor(String colorString) Returns a newStyleConfwith the provided inner Background color in the form of a string.Returns a newStyleConfwith the provided border widths and border color.Returns a newStyleConfwith the provided border width and border color.Returns a newStyleConfwith the provided border width and border colors.Returns a newStyleConfwith the provided border width and border color in the form of a string.Returns a newStyleConfwith the provided border width and border colors in the form of strings.Returns a newStyleConfwith the provided width and color used to define the border for the specified edge of the component.Returns a newStyleConfwith the provided width and color string used to define the border for the specified edge of the component.borderColor(Color color) Returns a newStyleConfwith the provided border color.borderColor(String colorString) Returns an updatedStyleConfwith the provided border color in the form of a string.borderColors(Color top, Color right, Color bottom, Color left) Returns a newStyleConfwith the provided border colors, which are stored in the order of top, right, bottom, left.borderColors(String top, String right, String bottom, String left) Returns a newStyleConfwith the provided border colors in the form of strings.borderRadius(double radius) Returns a newStyleConfwith the provided border radius set for all 4 corners of the target component.borderRadius(double arcWidth, double arcHeight) Returns a newStyleConfwith the provided border arc width and arc height set for all 4 corners of the target component.borderRadiusAt(UI.Corner corner, double radius) Returns a newStyleConfwith the provided border radius for the specified corner.borderRadiusAt(UI.Corner corner, double arcWidth, double arcHeight) Returns a newStyleConfwith the provided border arc width and arc height for the specified corner.borderWidth(double width) Returns a newStyleConfwith the provided border width.borderWidthAt(UI.Edge edge, double width) Returns a newStyleConfwith the provided border width for the specified edge.borderWidths(double topBottom, double leftRight) Returns a newStyleConfwith the provided top/bottom and left/right border widths.borderWidths(double top, double right, double bottom, double left) Returns a newStyleConfwith the provided top, right, bottom and left border widths.final ComponentStyleDelegate<C> componentFont(Configurator<FontConf> fontStyler) Returns a newStyleConfwith the provided font style applied to the font property of the component (seeComponent.getFont()).Defines the cursor type for thisJComponentbased on the providedCursorvalue.Defines the cursor type for thisJComponentbased on the predefinedUI.Cursorvalues.fontAlignment(UI.Alignment alignment) Use this to define the horizontal and vertical alignment of the default font of the component.fontAlignment(UI.HorizontalAlignment alignment) Use this to define the horizontal alignment of the default font of the component.fontAlignment(UI.VerticalAlignment alignment) Use this to define the vertical alignment of the default font of the component.fontBackgroundColor(Color color) fontBackgroundColor(String colorString) Creates a newStyleConfwhere the font color is set to a color parsed from the provided string.fontBackgroundPaint(@Nullable Paint paint) Updates this style delegate with the suppliedPaintobject used for the background of the font, which translates to theTextAttribute.BACKGROUNDattribute.fontBold(boolean bold) Makes the font bold or not bold depending on the value of theisBoldparameter.Creates a newStyleConfwhere the font color is set to a color parsed from the provided string.fontFamily(String name) Returns a newStyleConfwith the provided font family name.fontItalic(boolean italic) Makes the font italic or not italic depending on the value of theitalicparameter.Creates an updated style config with the provided font paint applied to all font configurations of the component.fontSelectionColor(Color color) fontSelectionColor(String colorString) Creates a newStyleConfwhere the font selection color is set to a color parsed from the provided string.fontSize(int size) Returns a newStyleConfwith the provided font size.fontSpacing(float spacing) The font spacing, which is also known as tracking, is the space between characters in a font.fontStrikeThrough(boolean strikeThrough) Makes the font struck through or not struck through depending on the value of thestrikeThroughparameter.fontStyle(UI.FontStyle style) Determines if the font should be plain, bold, italic or bold and italic based on the providedUI.FontStyleparameter, which may beUI.FontStyle.PLAIN,UI.FontStyle.BOLD,UI.FontStyle.ITALICorUI.FontStyle.BOLD_ITALIC.
Note that this will override any previous bold or italic settings.fontTransform(@Nullable AffineTransform transform) TheAffineTransformproperty of a font defines how the font is rotated, scaled, skewed or translated.fontUnderline(boolean underline) Makes the font underlined or not underlined depending on the value of theunderlineparameter.fontWeight(float weight) Use this to define the weight of the default font of the component.foregroundColor(Color color) Returns a newStyleConfwith the provided foreground color.foregroundColor(String colorString) Returns a newStyleConfwith the provided foreground color in the form of a string.foundationColor(double r, double g, double b) Returns a newStyleConfwith 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.foundationColor(double r, double g, double b, double a) Returns a newStyleConfwith 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.foundationColor(Color color) Returns a newStyleConfwith the provided background foundation color.foundationColor(String colorString) Returns a newStyleConfwith the provided background foundation color in the form of a string.floatgetScale()A convenient delegate method toUI.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).gradient(String shadeName, Configurator<GradientConf> styler) This method makes it possible to define multiple background gradient for a single component on theUI.Layer.BACKGROUNDlayer, by giving the gradient config a unique name.gradient(Configurator<GradientConf> styler) This method makes it possible to define a background shade for your components.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.gradient(UI.Layer layer, Configurator<GradientConf> styler) This method makes it possible to define a gradient effect on a particular layer for your components.height(double height) Defines the height of thisJComponent.Returns a newStyleConfwith the providedImageIconas the icon for the current component (seecomponent()).icon(ImageIcon icon, UI.FitComponent fit) Returns a newStyleConfwith the providedImageIconas the icon for the current component (seecomponent()) and the provided fit mode determining how the icon should be fitted to the component.icon(IconDeclaration icon) Returns a newStyleConfwith the providedIconDeclarationas the source for the icon of the current component (seecomponent()).icon(IconDeclaration icon, UI.FitComponent fit) Returns a newStyleConfwith the providedIconDeclarationas the source for the icon of the current component (seecomponent()) and the provided fit mode determining how the icon should be fitted to the component.image(String imageName, Configurator<ImageConf> styler) This method makes it possible to define multiple background styles for a single component rendered on theUI.Layer.BACKGROUNDlayer, by giving the background config a unique name.image(Configurator<ImageConf> styler) Allows for the rendering of a background image on your components.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.image(UI.Layer layer, Configurator<ImageConf> styler) Allows for the rendering of an image on a particular component layer.Defines theMigLayoutbased layout constraints and column layout constraints of thisJComponentin the form of aString.Defines theMigLayoutbased layout constraints column layout constraints and row layout constraints of thisJComponentin the form of aString.Use this to define the layout manager for thisJComponentusing aLayoutobject.layout(LayoutConstraint constraintAttr) Defines the layoutMigLayoutconstraints for thisJComponentin the form of aLayoutConstraint(seeUILayoutConstants.FILL,UILayoutConstants.FILL_X,UILayoutConstants.FILL_Y...).margin(double margin) Creates a newStyleConfwith the provided margin distance for all sides of the component.margin(double top, double right, double bottom, double left) Creates a newStyleConfwith the provided top, right, left and bottom margin distances.marginBottom(double margin) Creates a newStyleConfwith the provided margin distance for the bottom side of the component.marginHorizontal(double margin) Creates a newStyleConfwith the provided margin distance for the left and right sides of the component.marginLeft(double margin) Creates a newStyleConfwith the provided margin distance for the left side of the component.marginRight(double margin) Creates a newStyleConfwith the provided margin distance for the right side of the component.marginTop(double margin) Creates a newStyleConfwith the provided margin distance for the top side of the component.marginVertical(double margin) Creates a newStyleConfwith the provided margin distance for the top and bottom sides of the component.maxHeight(double maxHeight) Defines the maximum height for thisJComponent.maxSize(double width, double height) Defines the maximumDimensionfor thisJComponent.Defines the maximumSizefor thisJComponent.maxWidth(double maxWidth) Defines the maximum width for thisJComponent.minHeight(double minHeight) Defines the minimum height for thisJComponent.minSize(double width, double height) Defines the minimumDimensionfor thisJComponent.Defines the minimum size for thisJComponentin the form of aSizeobject.minWidth(double minWidth) Defines the minimum width for thisJComponent.noise(String noiseName, Configurator<NoiseConf> styler) This method makes it possible to define a background noise for your components.noise(Configurator<NoiseConf> styler) This method makes it possible to define a background noise for your components.noise(UI.Layer layer, String noiseName, Configurator<NoiseConf> styler) This method makes it possible to define a background noise for your components.orientation(UI.ComponentOrientation orientation) Determines how the component is oriented, typically with respect to the text direction and where content originates.padding(double padding) Creates a newStyleConfwith the provided padding distance for all sides of the component.padding(double top, double right, double bottom, double left) Creates a newStyleConfwith the provided top, right, left and bottom pad distances.paddingBottom(double padding) Creates a newStyleConfwith the provided padding distance for the bottom side of the component.paddingHorizontal(double padding) Creates a newStyleConfwith the provided padding distance for the left and right sides of the component.paddingLeft(double padding) Creates a newStyleConfwith the provided padding distance for the left side of the component.paddingRight(double padding) Creates a newStyleConfwith the provided padding distance for the right side of the component.paddingTop(double padding) Creates a newStyleConfwith the provided padding distance for the top side of the component.paddingVertical(double padding) Creates a newStyleConfwith the provided padding distance for the top and bottom sides of the component.Returns a newStyleConfwith the provided namedPainter, which will be called using theGraphics2Dinstance of the current component.Returns a newStyleConfwith the provided customPainter, which will be called using theGraphics2Dof the current component.painter(UI.Layer layer, UI.ComponentArea clipArea, String painterName, Painter painter) Returns a newStyleConfwith the provided namedPainter, which will be called using theGraphics2Dinstance of the current component.painter(UI.Layer layer, UI.ComponentArea clipArea, Painter painter) Returns a newStyleConfwith the provided customPainter, which will be called using theGraphics2Dof the current component.parent()Exposes the parentContainerof theJComponentdelegated by thisComponentStyleDelegatethrough anOptionalin case the parent is null.parentFilter(Configurator<FilterConf> filterStyler) Use this to peek at theJComponentof thisComponentStyleDelegateto perform some style-related component specific actions on it which are otherwise not found in theComponentStyleDelegateAPI.prefHeight(double preferredHeight) Defines the preferred height for thisJComponent.prefSize(double width, double height) Defines the preferredDimensionfor thisJComponent.Defines the preferredSizefor thisJComponent.prefWidth(double preferredWidth) Defines the preferred width for thisJComponent.Allow for the specification of client properties on the styled component.floatscale()A convenient delegate method toUI.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).doublescale(double value) Use this method inside customPainterimplementations (seepainter(UI.Layer, Painter)) to scale adoublevalue by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).floatscale(float value) Use this method inside customPainterimplementations (seepainter(UI.Layer, swingtree.api.Painter)) to scale afloatvalue by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).intscale(int value) Use this method inside customPainterimplementations (seepainter(UI.Layer, swingtree.api.Painter)) to scale anintvalue by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).shadow(String shadowName, Configurator<ShadowConf> styler) This method makes it possible to define multiple shadows for a single component on theUI.Layer.CONTENTlayer, by giving the shadow config a unique name.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.shadowBlurRadius(double radius) Returns a newStyleConfwith the provided shadow blur radius applied to all shadow configs.shadowColor(double r, double g, double b) Returns a newStyleConfwith 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.shadowColor(double r, double g, double b, double a) Returns a newStyleConfwith 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.shadowColor(Color color) Returns a newStyleConfwith the provided shadow color applied to the default shadow.shadowColor(String colorString) Returns a newStyleConfwith the provided shadow color in the form of a string.shadowHorizontalOffset(double offset) Returns a newStyleConfwith the provided horizontal shadow offset applied to all shadow configs.shadowIsInset(boolean inwards) Use this to control whether your shadows should be rendered inwards or outwards.shadowOffset(double horizontalAndVerticalOffset) Returns a newStyleConfwith the provided horizontal and vertical shadow offset.shadowOffset(double horizontalOffset, double verticalOffset) Returns a newStyleConfwith the provided shadow offset applied to all shadow configs.shadowSpreadRadius(double radius) Returns a newStyleConfwith the provided shadow spread radius applied to all shadow configs.shadowVerticalOffset(double offset) Returns a newStyleConfwith the provided vertical shadow offset applied to all shadow configs.shapeOf(UI.ComponentArea area) As a delegate to the underlying component, you can use this method to access a specificUI.ComponentAreaof the component.size(double width, double height) Defines the size of thisJComponent.Defines the size of thisJComponent.text(String textName, Configurator<TextConf> styler) text(Configurator<TextConf> styler) text(UI.Layer layer, String textName, Configurator<TextConf> styler) toString()width(double width) Defines the width of thisJComponent.
-
Method Details
-
component
Returns theJComponentthisComponentStyleDelegateis defining aStyleConffor. 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 aJCheckBoxbased on whether it is selected or not...- Returns:
- The
JComponentthisComponentStyleDelegateis for.
-
parent
Exposes the parentContainerof theJComponentdelegated by thisComponentStyleDelegatethrough anOptionalin 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
Containerof theJComponentthisComponentStyleDelegateis for.
-
peek
Use this to peek at theJComponentof thisComponentStyleDelegateto perform some style-related component specific actions on it which are otherwise not found in theComponentStyleDelegateAPI.- Parameters:
peeker- APeekerthat takes theJComponentof thisComponentStyleDelegate- Returns:
- This
ComponentStyleDelegateinstance.
-
applyIf
Allows you to apply styles based on a condition. So if the first argument, the condition, is true, then it causes the suppliedStylerto 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:
This is conceptually similar toUI.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) );UIForAnything.applyIf(boolean, Consumer)with the difference that it is based on aStylerinstead 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 providedstylershould be executed.styler- A supplier for- Returns:
- This instance if the condition is false, or the supplied
stylerthrew an exception, a new style delegate updated according to thestyler.
-
shapeOf
As a delegate to the underlying component, you can use this method to access a specificUI.ComponentAreaof the component. This method returns anOptionalvalue, which means that the component area may not be present. TheUI.ComponentArea.BORDERfor example, may not be present in case of there not being a border width defined throughUIForAnySwing.withStyle(Styler).See
ComponentExtension.getComponentArea(UI.ComponentArea)for more information.- Parameters:
area- The component area to access.- Returns:
- An optional value that contains the component area if it is present.
-
margin
Creates a newStyleConfwith 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 (seeborderWidth(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
ComponentStyleDelegatewith the provided padding distances.
-
margin
Creates a newStyleConfwith 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 (seeborderWidth(double),backgroundColor(Color),shadowColor(Color)).- Parameters:
margin- The margin distance in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided margin distance.
-
marginTop
Creates a newStyleConfwith 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 (seeborderWidth(double),backgroundColor(Color),shadowColor(Color)).- Parameters:
margin- The margin distance in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided margin distance.
-
marginRight
Creates a newStyleConfwith 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 (seeborderWidth(double),backgroundColor(Color),shadowColor(Color)).- Parameters:
margin- The margin distance in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided margin distance.
-
marginBottom
Creates a newStyleConfwith 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 (seeborderWidth(double),backgroundColor(Color),shadowColor(Color)).- Parameters:
margin- The margin distance in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided margin distance.
-
marginLeft
Creates a newStyleConfwith 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 (seeborderWidth(double),backgroundColor(Color),shadowColor(Color)).- Parameters:
margin- The margin distance in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided margin distance.
-
marginVertical
Creates a newStyleConfwith 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 (seeborderWidth(double),backgroundColor(Color),shadowColor(Color)).- Parameters:
margin- The margin distance in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided margin distance.
-
marginHorizontal
Creates a newStyleConfwith 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 (seeborderWidth(double),backgroundColor(Color),shadowColor(Color)).- Parameters:
margin- The margin distance in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided margin distance.
-
padding
Creates a newStyleConfwith 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. (seeborderWidth(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
ComponentStyleDelegatewith the provided padding distances.
-
padding
Creates a newStyleConfwith 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. (seeborderWidth(double),backgroundColor(Color),shadowColor(Color)).- Parameters:
padding- The padding distance in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided padding distance.
-
paddingTop
Creates a newStyleConfwith 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. (seeborderWidth(double),backgroundColor(Color),shadowColor(Color)).- Parameters:
padding- The padding distance in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided padding distance.
-
paddingRight
Creates a newStyleConfwith 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 (seeborderWidth(double),backgroundColor(Color),shadowColor(Color)).- Parameters:
padding- The padding distance in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided padding distance.
-
paddingBottom
Creates a newStyleConfwith 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. (seeborderWidth(double),backgroundColor(Color),shadowColor(Color)).- Parameters:
padding- The padding distance in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided padding distance.
-
paddingLeft
Creates a newStyleConfwith 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. (seeborderWidth(double),backgroundColor(Color),shadowColor(Color)).- Parameters:
padding- The padding distance in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided padding distance.
-
paddingVertical
Creates a newStyleConfwith 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. (seeborderWidth(double),backgroundColor(Color),shadowColor(Color)).- Parameters:
padding- The padding distance in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided padding distance.
-
paddingHorizontal
Creates a newStyleConfwith 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. (seeborderWidth(double),backgroundColor(Color),shadowColor(Color)).- Parameters:
padding- The padding distance in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided padding distance.
-
border
Returns a newStyleConfwith the provided border width and border color. The border will be rendered with an inset space based on the margin defined by theStyleConf.- Parameters:
width- The border width in pixels.color- The border color.- Returns:
- A new
ComponentStyleDelegatewith the provided border width and border color.
-
border
public ComponentStyleDelegate<C> border(double width, Color top, Color right, Color bottom, Color left) Returns a newStyleConfwith the provided border width and border colors. The border will be rendered with an inset space based on the margin defined by theStyleConf. 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
ComponentStyleDelegatewith the provided border width and border colors.
-
border
public ComponentStyleDelegate<C> border(double top, double right, double bottom, double left, Color color) Returns a newStyleConfwith the provided border widths and border color. The border will be rendered with an inset space based on the margin defined by theStyleConf.- 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
ComponentStyleDelegatewith the provided border widths and border color.
-
border
Returns a newStyleConfwith 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 (SeeUIFactoryMethods.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 theStyleConf.- Parameters:
width- The border width in pixels.colorString- The border color.- Returns:
- A new
ComponentStyleDelegatewith the provided border width and border color.
-
border
public ComponentStyleDelegate<C> border(double width, String top, String right, String bottom, String left) Returns a newStyleConfwith 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 theStyleConf.- 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
ComponentStyleDelegatewith the provided border width and border colors.
-
borderWidth
Returns a newStyleConfwith 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)orborderColor(String). You may also specify different colors for each side of the border throughborderColors(Color, Color, Color, Color)orborderColors(String, String, String, String).- Parameters:
width- The border width in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided border width.
-
borderColors
Returns a newStyleConfwith 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 theStyleConf.Instead of null, the
UI.Color.UNDEFINEDconstant 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
ComponentStyleDelegatewith the provided border colors.
-
borderColors
Returns a newStyleConfwith 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 (SeeUIFactoryMethods.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 theStyleConf.- 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
ComponentStyleDelegatewith the provided border colors.
-
borderWidthAt
Returns a newStyleConfwith 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)orborderColor(String).- Parameters:
edge- The edge to set the border width for.width- The border width in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided border width for the specified edge.
-
borderAt
Returns a newStyleConfwith 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 theStyleConf.- Parameters:
edge- The edge to set the border width and color for, you may useUI.Edge.EVERYto set the same width and color for all edges.width- The border width in pixels.color- The border color.- Returns:
- A new
ComponentStyleDelegatewith the provided border width and color for the specified edge.
-
borderAt
Returns a newStyleConfwith 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 theStyleConf.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 useUI.Edge.EVERYto set the same width and color for all edges.width- The border width in pixels.colorString- The border color.- Returns:
- A new
ComponentStyleDelegatewith the provided border width and color for the specified edge.
-
borderWidths
Returns a newStyleConfwith 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)orborderColor(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
ComponentStyleDelegatewith the provided top, right, bottom and left border widths. - See Also:
-
borderWidths
Returns a newStyleConfwith 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)orborderColor(String).- Parameters:
topBottom- The top and bottom border width in pixels.leftRight- The left and right border width in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided top/bottom and left/right border widths. - See Also:
-
borderColor
Returns a newStyleConfwith the provided border color. The border will be rendered with an inset space based on the padding defined by theStyleConf.- Parameters:
color- The border color.- Returns:
- A new
ComponentStyleDelegatewith the provided border color.
-
borderColor
Returns an updatedStyleConfwith 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 theStyleConf.- Parameters:
colorString- The border color.- Returns:
- A new
ComponentStyleDelegatewith the provided border color.
-
borderRadius
Returns a newStyleConfwith 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 thisStyleConf.- Parameters:
radius- The border radius in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided border radius.
-
borderRadius
Returns a newStyleConfwith 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 thisStyleConf.- Parameters:
arcWidth- The border arc width in pixels.arcHeight- The border arc height in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided border arc width and arc height.
-
borderRadiusAt
public ComponentStyleDelegate<C> borderRadiusAt(UI.Corner corner, double arcWidth, double arcHeight) Returns a newStyleConfwith 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 thisStyleConf.- 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
ComponentStyleDelegatewith the provided border arc width and arc height for the specified corner.
-
borderRadiusAt
Returns a newStyleConfwith 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 thisStyleConf.- Parameters:
corner- The corner to apply the border radius to.radius- The border radius in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided border radius for the specified corner.
-
icon
Returns a newStyleConfwith the providedImageIconas the icon for the current component (seecomponent()). Note that this will only produce a result for components that actually support icons. Like for example all the variousAbstractButtonsubclasses,JLabelandJIcon.- Parameters:
icon- The icon.- Returns:
- A new
ComponentStyleDelegatewith the provided icon.
-
icon
Returns a newStyleConfwith the providedImageIconas the icon for the current component (seecomponent()) 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 variousAbstractButtonsubclasses,JLabelandJIcon.- Parameters:
icon- The icon in the form of anImageIcon.fit- The fit mode for the icon (mostly intended forSvgIcon).- Returns:
- A new
ComponentStyleDelegatewith the provided icon.
-
icon
Returns a newStyleConfwith the providedIconDeclarationas the source for the icon of the current component (seecomponent()). Note that this will only have an effect for components that support icons. Like for example all the variousAbstractButtonsubclasses,JLabelandJIcon.- Parameters:
icon- The icon declaration, which will be resolved to anImageIcon.- Returns:
- A new
ComponentStyleDelegatewith the provided icon.
-
icon
Returns a newStyleConfwith the providedIconDeclarationas the source for the icon of the current component (seecomponent()) 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 variousAbstractButtonsubclasses,JLabelandJIcon.- Parameters:
icon- The icon declaration, which will be resolved to anImageIcon.fit- The fit mode for the icon (mostly intended forSvgIcon).- Returns:
- A new
ComponentStyleDelegatewith the provided icon.
-
foundationColor
Returns a newStyleConfwith the provided background foundation color. The foundation color covers theUI.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
ComponentStyleDelegatewith the provided background color.
-
foundationColor
Returns a newStyleConfwith 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 theUI.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
ComponentStyleDelegatewith the provided background color.
-
foundationColor
Returns a newStyleConfwith 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 theUI.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
ComponentStyleDelegatewith the provided background color.
-
foundationColor
Returns a newStyleConfwith 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 theUI.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
ComponentStyleDelegatewith the provided background color.
-
backgroundColor
Returns a newStyleConfwith the provided inner Background color. The background color covers theUI.ComponentArea.INTERIOR, which, when going inwards, starts at the end of the component's border area (UI.ComponentArea.BORDER), (which is defined byUI.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
ComponentStyleDelegatewith the provided inner background color.
-
backgroundColor
Returns a newStyleConfwith 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 theUI.ComponentArea.INTERIOR, which, when going inwards, starts at the end of the component's border area (UI.ComponentArea.BORDER), (which is defined byUI.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
ComponentStyleDelegatewith the provided inner background color.
-
backgroundColor
Returns a newStyleConfwith 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 theUI.ComponentArea.INTERIOR, which, when going inwards, starts at the end of the component's border area (UI.ComponentArea.BORDER), (which is defined byUI.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
ComponentStyleDelegatewith the provided inner background color.
-
backgroundColor
Returns a newStyleConfwith 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 theUI.ComponentArea.INTERIOR, which, when going inwards, starts at the end of the component's border area (UI.ComponentArea.BORDER), (which is defined byUI.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
ComponentStyleDelegatewith the provided inner background color.
-
painter
Returns a newStyleConfwith the provided customPainter, which will be called using theGraphics2Dof 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 haveObject.hashCode()andObject.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 thePainter.of(Object, Painter)factory method to create a painter that has the withObject.hashCode()andObject.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 theUI.Layer.BACKGROUNDwill be painted first, followed by theUI.Layer.CONTENTand so on...
The following layers are available:painter- A custom painter, which receives theGraphics2Dinstance of the current component.- Returns:
- A new
ComponentStyleDelegatewith the provided background renderer.
-
painter
public ComponentStyleDelegate<C> painter(UI.Layer layer, UI.ComponentArea clipArea, Painter painter) Returns a newStyleConfwith the provided customPainter, which will be called using theGraphics2Dof the current component. You may use this to render a custom background for the component on the specifiedUI.LayerandUI.ComponentArea.
Note that your custom painter will yield the best performance if they are value based in the sense that they haveObject.hashCode()andObject.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 thePainter.of(Object, Painter)factory method to create a painter that has the withObject.hashCode()andObject.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 theUI.Layer.BACKGROUNDwill be painted first, followed by theUI.Layer.CONTENTand 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 theGraphics2Dinstance of the current component.- Returns:
- A new
ComponentStyleDelegatewith the provided background renderer.
-
painter
Returns a newStyleConfwith the provided namedPainter, which will be called using theGraphics2Dinstance of the current component. You may use this to render custom styles for the component...
The name can be used to overridePainterinstances 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 haveObject.hashCode()andObject.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 thePainter.of(Object, Painter)factory method to create a painter that has the withObject.hashCode()andObject.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 theUI.Layer.BACKGROUNDwill be painted first, followed by theUI.Layer.CONTENTand so on...
The following layers are available:painterName- The name of the painter.painter- The custom painter lambda to which theGraphics2Dinstance of the current component will be passed.- Returns:
- A new
ComponentStyleDelegatewith the provided background renderer.
-
painter
public ComponentStyleDelegate<C> painter(UI.Layer layer, UI.ComponentArea clipArea, String painterName, Painter painter) Returns a newStyleConfwith the provided namedPainter, which will be called using theGraphics2Dinstance of the current component. You may use this to render custom styles for the component...
The name can be used to overridePainterinstances 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 haveObject.hashCode()andObject.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 thePainter.of(Object, Painter)factory method to create a painter that has the withObject.hashCode()andObject.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 theUI.Layer.BACKGROUNDwill be painted first, followed by theUI.Layer.CONTENTand 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 theGraphics2Dinstance of the current component will be passed.- Returns:
- A new
ComponentStyleDelegatewith the provided background renderer.
-
foregroundColor
Returns a newStyleConfwith the provided foreground color.- Parameters:
color- The foreground color.- Returns:
- A new
ComponentStyleDelegatewith the provided foreground color.
-
foregroundColor
Returns a newStyleConfwith 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
ComponentStyleDelegatewith the provided foreground color.
-
shadowHorizontalOffset
Returns a newStyleConfwith 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 thisStyleConf. Note that in order to see the shadow, you may also need to callshadowSpreadRadius(double),shadowBlurRadius(double)andshadowColor(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 usingshadow(String, Configurator).- Parameters:
offset- The shadow offset in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided horizontal shadow offset.
-
shadowVerticalOffset
Returns a newStyleConfwith 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 thisStyleConf. Note that in order to see the shadow, you may also need to callshadowSpreadRadius(double),shadowBlurRadius(double)andshadowColor(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 usingshadow(String, Configurator).- Parameters:
offset- The shadow offset in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided vertical shadow offset.
-
shadowOffset
Returns a newStyleConfwith the provided shadow offset applied to all shadow configs. The shadow will be rendered with an inset space based on the padding defined by thisStyleConf. Note that in order to see the shadow, you may also need to callshadowSpreadRadius(double),shadowBlurRadius(double)andshadowColor(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 usingshadow(String, Configurator).- Parameters:
horizontalOffset- The horizontal shadow offset in pixels.verticalOffset- The vertical shadow offset in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided shadow offset.
-
shadowOffset
Returns a newStyleConfwith the provided horizontal and vertical shadow offset. The shadow will be rendered with an inset space based on the padding defined by thisStyleConf. Note that in order to see the shadow, you may also need to callshadowSpreadRadius(double),shadowBlurRadius(double)andshadowColor(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 usingshadow(String, Configurator).- Parameters:
horizontalAndVerticalOffset- The horizontal and vertical shadow offset in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided shadow offset.
-
shadowBlurRadius
Returns a newStyleConfwith 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 thisStyleConf. Note that in order to see the shadow, you may also need to callshadowSpreadRadius(double)andshadowColor(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 usingshadow(String, Configurator).- Parameters:
radius- The shadow blur radius in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided shadow blur radius.
-
shadowSpreadRadius
Returns a newStyleConfwith 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 thisStyleConf. Note that in order to see the shadow, you may also need to callshadowBlurRadius(double)andshadowColor(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 usingshadow(String, Configurator).- Parameters:
radius- The shadow spread radius in pixels.- Returns:
- A new
ComponentStyleDelegatewith the provided shadow spread radius.
-
shadowColor
Returns a newStyleConfwith the provided shadow color applied to the default shadow. Note that in order to see the shadow, you may also need to callshadowBlurRadius(double)andshadowSpreadRadius(double).
The shadow will be rendered on theUI.Layer.CONTENTlayer, if you want it to be rendered on a different layer, you may want to take a look atshadow(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 usingshadow(String, Configurator)(and which are also rendered on theUI.Layer.CONTENTlayer).- Parameters:
color- The shadow color.- Returns:
- A new
ComponentStyleDelegatewith the provided shadow color.
-
shadowColor
Returns a newStyleConfwith 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 callshadowBlurRadius(double)andshadowSpreadRadius(double).
The shadow will be rendered on theUI.Layer.CONTENTlayer, if you want it to be rendered on a different layer, you may want to take a look atshadow(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 usingshadow(String, Configurator)(and which are also rendered on theUI.Layer.CONTENTlayer).- Parameters:
colorString- The shadow color.- Returns:
- A new
ComponentStyleDelegatewith the provided shadow color.
-
shadowColor
Returns a newStyleConfwith 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 callshadowBlurRadius(double)andshadowSpreadRadius(double).
The shadow will be rendered on theUI.Layer.CONTENTlayer, if you want it to be rendered on a different layer, you may want to take a look atshadow(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 usingshadow(String, Configurator)(and which are also rendered on theUI.Layer.CONTENTlayer).- 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
ComponentStyleDelegatewith the provided shadow color.
-
shadowColor
Returns a newStyleConfwith 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 callshadowBlurRadius(double)andshadowSpreadRadius(double).
The shadow will be rendered on theUI.Layer.CONTENTlayer, if you want it to be rendered on a different layer, you may want to take a look atshadow(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 usingshadow(String, Configurator)(and which are also rendered on theUI.Layer.CONTENTlayer).- 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
ComponentStyleDelegatewith the provided shadow color.
-
shadowIsInset
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 usingshadow(String, Configurator).
The default value isfalse.- Parameters:
inwards- Whether the shadow should be rendered inwards or outwards.- Returns:
- A new
ComponentStyleDelegatewith the provided shadow inset flag.
-
shadow
This method makes it possible to define multiple shadows for a single component on theUI.Layer.CONTENTlayer, 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:
Note that the shadows will be rendered in alphabetical order based on their name (within a particular layer).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) )- Parameters:
shadowName- The name of the shadow.styler- A function that takes aShadowConfand returns a newShadowConf.- Returns:
- A new
ComponentStyleDelegatewith 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:
Note that the shadows will be rendered in alphabetical order based on their name (within a particular layer).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) )- Parameters:
layer- The layer of the shadow is an enum instance which gives the shadow effect a rank in the painting order. So theUI.Layer.BACKGROUNDwill be painted first, followed by theUI.Layer.CONTENTand so on...
The following layers are available:shadowName- The name of the shadow.styler- A function that takes aShadowConfand returns a newShadowConf.- Returns:
- A new
ComponentStyleDelegatewith a named shadow defined by the provided styler lambda.
-
gradient
This method makes it possible to define multiple background gradient for a single component on theUI.Layer.BACKGROUNDlayer, 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:
Note that the background shades will be rendered in alphabetical order based on the name of the shade.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)) ) )
This method translates togradient(UI.Layer, String, Configurator)but with the layer set toUI.Layer.BACKGROUND.- Parameters:
shadeName- The name of the background shade.styler- A function that takes aGradientConfand returns a newGradientConf.- Returns:
- A new
ComponentStyleDelegatewith 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:
Note that within a particular layer the gradients will be rendered in alphabetical order based on the provided name.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)) ) )- Parameters:
layer- The layer on which the gradient should be rendered.shadeName- The name of the background shade.styler- A function that takes aGradientConfand returns a newGradientConf.- Returns:
- A new
ComponentStyleDelegatewith a named background shade defined by the provided styler lambda.
-
gradient
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:
This method translates toUI.panel() .withStyle( it -> it .gradient( conf -> conf .colors("#000000", "#000000") .transition(UI.Transition.TOP_TO_BOTTOM) ) )gradient(UI.Layer, String, Configurator)but with the layer set toUI.Layer.BACKGROUNDand the name being the "default" style name- Parameters:
styler- A function that takes aGradientConfand returns a newGradientConf.- Returns:
- A new
ComponentStyleDelegatewith a background shade defined by the provided styler lambda.
-
gradient
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:
Note that this method translates toUI.panel() .withStyle( it -> it .gradient(UI.Layer.BACKGROUND, conf -> conf .colors("#000000", "#000000") .transition(UI.Transition.TOP_TO_BOTTOM) ) )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 aGradientConfand returns a newGradientConf.- Returns:
- A new
ComponentStyleDelegatewith a background shade 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 it:
Note that this method translates toUI.panel() .withStyle( it -> it .noise("my-noise" conf -> conf .scale(2, 3).rotation(45) .colors(Color.BLACK, Color.WHITE) .offset(64,85) ) )noise(UI.Layer, String, Configurator)but with the layer set toUI.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 aNoiseConfand returns a newNoiseConf.- Returns:
- A new
ComponentStyleDelegatewith 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.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 aNoiseConfand returns a newNoiseConf.- Returns:
- A new
ComponentStyleDelegatewith 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:
Note that this method translates toUI.panel() .withStyle( it -> it .noise( conf -> conf .scale(2, 3).rotation(45) .colors(Color.BLACK, Color.WHITE) .offset(64,85) ) )noise(UI.Layer, String, Configurator)but with the layer set toUI.Layer.BACKGROUNDand the name being the "default" style name.- Parameters:
styler- A function that takes aNoiseConfand returns a newNoiseConf.- Returns:
- A new
ComponentStyleDelegatewith a background noise defined by the provided styler lambda.
-
image
This method makes it possible to define multiple background styles for a single component rendered on theUI.Layer.BACKGROUNDlayer, 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:
Note that the background images will be rendered in alphabetical order based on the name of the image.UI.panel() .withStyle( it -> it .image("ground 1", image -> image .image(loadImageFrom("my/path/to/image1.png")) ) .ground("ground 2", ground -> ground .color("blue") ) )- Parameters:
imageName- The name of the background image.styler- A function that takes aImageConfand returns a newImageConf.- Returns:
- A new
ComponentStyleDelegatewith 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:
Note that the background images will be rendered in alphabetical order based on the name of the image.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") ) )- 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 aImageConfand returns a newImageConf.- Returns:
- A new
ComponentStyleDelegatewith 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:
Note that this method translates toUI.panel() .withStyle( it -> it .image( image -> image .image(loadImageFrom("my/path/to/image1.png")) .color("green") ) )image(UI.Layer, String, Configurator)but with the layer set toUI.Layer.BACKGROUNDand the name being the "default" style name.- Parameters:
styler- A function that takes aImageConfand returns a newImageConf.- Returns:
- A new
ComponentStyleDelegatewith a background image defined by the provided styler lambda.
-
image
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:
Note that this method translates toUI.panel() .withStyle( it -> it .image(UI.Layer.CONTENT, image -> image .image(loadImageFrom("my/path/to/image1.png")) .color("green") ) )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 aImageConfand returns a newImageConf.- Returns:
- A new
ComponentStyleDelegatewith a background image defined by the provided styler lambda.
-
text
Returns an updatedStyleConfwith a named text style configurator for the defaultTextConfof 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 theComponent.getFont()property of the component, you can usecomponentFont(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:
textName- The name of the text style that you want to define.styler- A configurator function that takes aTextConfand returns an updatedTextConf. The configurator function is called with the default text style of the component.- Returns:
- A new
ComponentStyleDelegatewith the provided text style. Each unique name creates an additional text style for the component. - Throws:
NullPointerException- If the provided styler or textName isnull.- See Also:
-
text
public ComponentStyleDelegate<C> text(UI.Layer layer, String textName, Configurator<TextConf> styler) Returns an updatedStyleConfwith the provided named text style configurator for the defaultTextConfof 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 theComponent.getFont()property of the component, you can usecomponentFont(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 aTextConfand returns an updatedTextConf. The configurator function is called with the default text style of the component.- Returns:
- A new
ComponentStyleDelegatewith the provided text style. - Throws:
NullPointerException- If the provided styler or textName isnull.- See Also:
-
text
Returns an updatedStyleConfwith the provided text style configurator for the defaultTextConfof 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 theComponent.getFont()property of the component, you can usecomponentFont(Configurator)instead.- Parameters:
styler- A configurator function that takes aTextConfand returns an updatedTextConf. The configurator function is called with the default text style of the component.- Returns:
- A new
ComponentStyleDelegatewith the provided text style. - Throws:
NullPointerException- If the provided styler isnull.- See Also:
-
property
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.
Anullreference is not allowed as a value and will throw aNullPointerException.- Parameters:
key- The key of the property.value- The value of the property.- Returns:
- A new
ComponentStyleDelegatewith the provided client property. - Throws:
NullPointerException- If the value isnull! (Use""to remove a property)- See Also:
-
parentFilter
-
componentFont
Returns a newStyleConfwith the provided font style applied to the font property of the component (seeComponent.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 (seetext(String, Configurator)), you can simply call the regular font styling methods such asfont(String, int),font(Font),fontFamily(String),fontSize(int),fontBold(boolean),fontItalic(boolean),fontUnderline(boolean)...- Parameters:
fontStyler- A function that takes aFontConfand returns a newFontConfthat is exclusively applied to the font property of the component.- Returns:
- A new
ComponentStyleDelegatewith the provided font style applied to the font property of the component.
-
font
Returns a newStyleConfwith 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 (seeTextConf).
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 usecomponentFont(Configurator).- Parameters:
name- The font name.size- The font size.- Returns:
- A new
ComponentStyleDelegatewith the provided font name and size.
-
fontFamily
Returns a newStyleConfwith 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 (seeTextConf).
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 usecomponentFont(Configurator).- Parameters:
name- The font name.- Returns:
- A new
ComponentStyleDelegatewith the provided font name.
-
font
Returns a newStyleConfwith the providedFont. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (seeTextConf).
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 usecomponentFont(Configurator).- Parameters:
font- TheFont.- Returns:
- A new
ComponentStyleDelegatewith the providedFont. - Throws:
NullPointerException- If the font isnull. UseUI.Font.UNDEFINEDto remove the font style.
-
fontSize
Returns a newStyleConfwith 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 (seeTextConf).
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 usecomponentFont(Configurator).- Parameters:
size- The font size.- Returns:
- A new
ComponentStyleDelegatewith the provided font size.
-
fontBold
Makes the font bold or not bold depending on the value of theisBoldparameter. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (seeTextConf).
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 usecomponentFont(Configurator).- Parameters:
bold- Whether the font should be bold or not.- Returns:
- A new
ComponentStyleDelegatewith the provided font boldness.
-
fontItalic
Makes the font italic or not italic depending on the value of theitalicparameter. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (seeTextConf).
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 usecomponentFont(Configurator).- Parameters:
italic- Whether the font should be italic or not.- Returns:
- A new
ComponentStyleDelegatewith the provided font italicness.
-
fontStyle
Determines if the font should be plain, bold, italic or bold and italic based on the providedUI.FontStyleparameter, which may beUI.FontStyle.PLAIN,UI.FontStyle.BOLD,UI.FontStyle.ITALICorUI.FontStyle.BOLD_ITALIC.
Note that this will override any previous bold or italic settings.- Parameters:
style- The font style in form of aUI.FontStyle.- Returns:
- An updated
ComponentStyleDelegatewith the provided font style.
-
fontUnderline
Makes the font underlined or not underlined depending on the value of theunderlineparameter. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (seeTextConf).
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 usecomponentFont(Configurator).- Parameters:
underline- Whether the font should be underlined or not.- Returns:
- A new
ComponentStyleDelegatewith the provided font underlinedness.
-
fontStrikeThrough
Makes the font struck through or not struck through depending on the value of thestrikeThroughparameter. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (seeTextConf).
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 usecomponentFont(Configurator).- Parameters:
strikeThrough- Whether the font should be struck through or not.- Returns:
- A new
ComponentStyleDelegatewith the provided font struck throughness.
-
fontColor
Creates a newStyleConfwhere the font color is set to the providedColor. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (seeTextConf).
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 usecomponentFont(Configurator).- Parameters:
color- TheColor.- Returns:
- A new
ComponentStyleDelegatewith the provided font color. - Throws:
NullPointerException- If the color isnull. UseUI.Color.UNDEFINEDto remove the font color style.
-
fontColor
Creates a newStyleConfwhere 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 (seeTextConf).
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 usecomponentFont(Configurator).- Parameters:
colorString- TheColoras a string.- Returns:
- A new
ComponentStyleDelegatewith the provided font color.
-
fontBackgroundColor
Creates a newStyleConfwhere the font background color is set to the providedColor. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (seeTextConf).
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 usecomponentFont(Configurator).- Parameters:
color- TheColor.- Returns:
- A new
ComponentStyleDelegatewith the provided font background color. - Throws:
NullPointerException- If the color isnull. UseUI.Color.UNDEFINEDto remove the font background color style.
-
fontBackgroundColor
Creates a newStyleConfwhere 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 (seeTextConf).
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 usecomponentFont(Configurator).- Parameters:
colorString- TheColoras a string.- Returns:
- A new
ComponentStyleDelegatewith the provided font color.
-
fontSelectionColor
Creates a newStyleConfwhere the font selection color is set to the providedColor. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (seeTextConf).
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 usecomponentFont(Configurator).- Parameters:
color- TheColor.- Returns:
- A new
ComponentStyleDelegatewith the provided font selection color. - Throws:
NullPointerException- If the color isnull. UseUI.Color.UNDEFINEDto remove the font selection color style.
-
fontSelectionColor
Creates a newStyleConfwhere 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 (seeTextConf).
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 usecomponentFont(Configurator).- Parameters:
colorString- TheColoras a string.- Returns:
- A new
ComponentStyleDelegatewith the provided font selection color.
-
fontTransform
TheAffineTransformproperty of a font defines how the font is rotated, scaled, skewed or translated. This method allows you to apply a customAffineTransformto the fonts of the component.- Parameters:
transform- TheAffineTransformto apply to the font.- Returns:
- A new
ComponentStyleDelegatewith the provided font transform.
-
fontPaint
Creates an updated style config with the provided font paint applied to all font configurations of the component.- Parameters:
paint- ThePaintto use for the foreground of the font, which translates to theTextAttribute.FOREGROUNDattribute.- Returns:
- A new
ComponentStyleDelegatewith the provided font paint.
-
fontBackgroundPaint
Updates this style delegate with the suppliedPaintobject used for the background of the font, which translates to theTextAttribute.BACKGROUNDattribute.- Parameters:
paint- ThePaintto use for the background of the font, which translates to theTextAttribute.BACKGROUNDattribute.- Returns:
- A new
ComponentStyleDelegatewith the provided font background paint.
-
fontWeight
Use this to define the weight of the default font of the component. The default value is 1.0 (seeTextAttribute.WEIGHT_REGULAR), whereas a bold font typically has a font weight of 2.0 (seeTextAttribute.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 usecomponentFont(Configurator).- Parameters:
weight- The weight of the font.- Returns:
- A new
ComponentStyleDelegatewith the provided font weight.
-
fontSpacing
The font spacing, which is also known as tracking, is the space between characters in a font. SeeTextAttribute.TRACKINGfor more information.- Parameters:
spacing- The spacing of the default font of the component, which translates to theTextAttribute.TRACKINGattribute.- Returns:
- A new
ComponentStyleDelegatewith the provided font spacing.
-
fontAlignment
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 (seeTextConf).
Also note that not all text based components support text alignment.- Parameters:
alignment- The horizontal alignment of the font. SeeUI.HorizontalAlignmentfor more information.- Returns:
- A new
ComponentStyleDelegatewith the provided font alignment. - Throws:
NullPointerException- If the alignment isnull. UseUI.HorizontalAlignment.UNDEFINEDto remove the font alignment style.
-
fontAlignment
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 (seeTextConf).
Also note that not all text based components support text alignment.- Parameters:
alignment- The vertical alignment of the font. SeeUI.VerticalAlignmentfor more information.- Returns:
- A new
ComponentStyleDelegatewith the provided font alignment. throws NullPointerException If the alignment isnull. UseUI.VerticalAlignment.UNDEFINEDto remove the font alignment style.
-
fontAlignment
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 (seeTextConf).
Also note that not all text based components support text alignment.- Parameters:
alignment- The horizontal and vertical alignment of the font. SeeUI.Alignmentfor more information.- Returns:
- A new
ComponentStyleDelegatewith the provided font alignment. throws NullPointerException If the alignment isnull. UseUI.Alignment.UNDEFINEDto remove the font alignment style.
-
minSize
Defines the minimumDimensionfor thisJComponent.
This ultimately translates toJComponent.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
ComponentStyleDelegatewith the provided minimumDimensionset to be later applied to the underlying component when the finalStyleConfis applied.
-
minSize
Defines the minimum size for thisJComponentin the form of aSizeobject.
This ultimately translates toJComponent.setMinimumSize(Dimension)on the underlying component, which will be called when all the other styles are applied and rendered.- Parameters:
size- The minimumSize.- Returns:
- A new
ComponentStyleDelegatewith the provided minimumSizeset to be later applied to the underlying component when the finalStyleConfis applied.
-
minWidth
Defines the minimum width for thisJComponent.
This ultimately translates toJComponent.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
ComponentStyleDelegatewith the provided minimum width set to be later applied to the underlying component when the finalStyleConfis applied.
-
minHeight
Defines the minimum height for thisJComponent.
This ultimately translates toJComponent.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
ComponentStyleDelegatewith the provided minimum height set to be later applied to the underlying component when the finalStyleConfis applied.
-
maxSize
Defines the maximumDimensionfor thisJComponent.
This ultimately translates toJComponent.setMaximumSize(Dimension)on the underlying component.
The passedDimensionwill be applied when all the other styles are applied and rendered.- Parameters:
width- The maximum width.height- The maximum height.- Returns:
- A new
ComponentStyleDelegatewith the provided maximumDimensionset to be later applied to the underlying component when the finalStyleConfis applied.
-
maxSize
Defines the maximumSizefor thisJComponent.
This ultimately translates toJComponent.setMaximumSize(Dimension)on the underlying component.
The passedSizewill be applied when all the other styles are applied and rendered.- Parameters:
maxSize- The maximumSize.- Returns:
- A new
ComponentStyleDelegatewith the provided maximumSizeset to be later applied to the underlying component when the finalStyleConfis applied.
-
maxWidth
Defines the maximum width for thisJComponent.
This ultimately translates toJComponent.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
ComponentStyleDelegatewith the provided maximum width set to be later applied to the underlying component when the finalStyleConfis applied.
-
maxHeight
Defines the maximum height for thisJComponent.
This ultimately translates toJComponent.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
ComponentStyleDelegatewith the provided maximum height set to be later applied to the underlying component when the finalStyleConfis applied.
-
prefSize
Defines the preferredSizefor thisJComponent.
This ultimately translates toJComponent.setPreferredSize(Dimension)on the underlying component.
The passedSizewill be applied when all the other styles are applied and rendered.- Parameters:
preferredSize- The preferredSize.- Returns:
- A new
ComponentStyleDelegatewith the provided preferredSizeset to be later applied to the underlying component when the finalStyleConfis applied.
-
prefSize
Defines the preferredDimensionfor thisJComponent.
This ultimately translates toJComponent.setPreferredSize(Dimension)on the underlying component.
The passedDimensionwill be applied when all the other styles are applied and rendered.- Parameters:
width- The preferred width.height- The preferred height.- Returns:
- A new
ComponentStyleDelegatewith the provided preferredDimensionset to be later applied to the underlying component when the finalStyleConfis applied.
-
prefWidth
Defines the preferred width for thisJComponent.
This ultimately translates toJComponent.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
ComponentStyleDelegatewith the provided preferred width set to be later applied to the underlying component when the finalStyleConfis applied.
-
prefHeight
Defines the preferred height for thisJComponent.
This ultimately translates toJComponent.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
ComponentStyleDelegatewith the provided preferred height set to be later applied to the underlying component when the finalStyleConfis applied.
-
size
Defines the size of thisJComponent.
This ultimately translates toComponent.setSize(Dimension)on the underlying component.- Parameters:
size- The width and height sizeDimension.- Returns:
- A new
ComponentStyleDelegatewith the providedSize(width and height) set to be later applied to the underlying component when the finalStyleConfis applied.
-
size
Defines the size of thisJComponent.
This ultimately translates toComponent.setSize(Dimension)on the underlying component.- Parameters:
width- The width.height- The height.- Returns:
- A new
ComponentStyleDelegatewith the provided size (width and height)Dimensionset to be later applied to the underlying component when the finalStyleConfis applied.
-
width
Defines the width of thisJComponent.
This ultimately translates toComponent.setSize(Dimension)on the underlying component.- Parameters:
width- The width.- Returns:
- A new
ComponentStyleDelegatewith the provided width set to be later applied to the underlying component when the finalStyleConfis applied.
-
height
Defines the height of thisJComponent.
This ultimately translates toComponent.setSize(Dimension)on the underlying component.- Parameters:
height- The height.- Returns:
- A new
ComponentStyleDelegatewith the provided height set to be later applied to the underlying component when the finalStyleConfis applied.
-
cursor
Defines the cursor type for thisJComponentbased on the predefinedUI.Cursorvalues.
If you want to specify a custom cursor implementation, usecursor(Cursor)instead.- Parameters:
cursor- TheUI.Cursorvalue.- Returns:
- A new
ComponentStyleDelegatewith the provided cursor type set to be later
-
cursor
Defines the cursor type for thisJComponentbased on the providedCursorvalue.
Use this method if you want to specify a custom cursor implementation, in case you merely want to pick one of the many predefinedUI.Cursorvalues, usecursor(UI.Cursor)instead.- Parameters:
cursor- TheCursorvalue.- Returns:
- A new
ComponentStyleDelegatewith the provided cursor type set to be later
-
orientation
Determines how the component is oriented, typically with respect to the text direction and where content originates.
This translates toComponent.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- TheUI.ComponentOrientation, which maps 1:1 to the AWTComponentOrientationconstants.- Returns:
- A new
ComponentStyleDelegatewith the providedUI.ComponentOrientationset to be later applied to the underlying component when the finalStyleConfis applied.
-
layout
Use this to define the layout manager for thisJComponentusing aLayoutobject.
Checkout the factory methods inLayoutfor creating different types of layout managers likeLayout.flow(),Layout.mig(String)orLayout.grid(int, int).- Parameters:
installer- TheLayoutto use for installing the layout.- Returns:
- A new
ComponentStyleDelegatewith the providedLayoutset to be later
-
layout
Defines the layoutMigLayoutconstraints for thisJComponentin the form of aString.
This ultimately translates toMigLayout.setLayoutConstraints(Object)on the underlying component.
Note that if this property is specified, the style engine will automatically install aMigLayouton the component if it does not already have one.- Parameters:
constraints- The layout constraints as aString.- Returns:
- A new
ComponentStyleDelegatewith the provided layout constraints set to be later
-
layout
Defines theMigLayoutbased layout constraints and column layout constraints of thisJComponentin the form of aString.
This ultimately translates toMigLayout.setLayoutConstraints(Object)as well asMigLayout.setColumnConstraints(Object)on the layout manager of the underlying component.
Note that if this property is specified, the style engine will automatically install aMigLayouton the component if it does not already have one.- Parameters:
constraints- The layout constraints as aString.columnConstraints- The column constraints as aString.- Returns:
- A new
ComponentStyleDelegatewith the provided layout constraints set to be later
-
layout
public ComponentStyleDelegate<C> layout(String constraints, String columnConstraints, String rowConstraints) Defines theMigLayoutbased layout constraints column layout constraints and row layout constraints of thisJComponentin the form of aString.
This ultimately translates toMigLayout.setLayoutConstraints(Object)as well asMigLayout.setColumnConstraints(Object)andMigLayout.setRowConstraints(Object)on the layout manager of the underlying component.
Note that if this property is specified, the style engine will automatically install aMigLayouton the component if it does not already have one.- Parameters:
constraints- The layout constraints as aString.columnConstraints- The column constraints as aString.rowConstraints- The row constraints as aString.- Returns:
- A new
ComponentStyleDelegatewith the provided layout constraints set to be later
-
addConstraint
Defines the component constraints of this component with respect to the parent component and its layout manager, in the form of aString.
This ultimately translates toMigLayout.setComponentConstraints(Component, Object)on the layout manager of the parent component.
Note that if this property is specified, the style engine will automatically install aMigLayouton the parent component if it does not already have one.- Parameters:
constraints- The component constraints as aString.- Returns:
- A new
ComponentStyleDelegatewith the provided component constraints set to be later
-
layout
Defines the layoutMigLayoutconstraints for thisJComponentin the form of aLayoutConstraint(seeUILayoutConstants.FILL,UILayoutConstants.FILL_X,UILayoutConstants.FILL_Y...).
This ultimately translates toMigLayout.setLayoutConstraints(Object)on the underlying component.
Note that if this property is specified, the style engine will automatically install aMigLayouton the component if it does not already have one.- Parameters:
constraintAttr- The layout constraints as aLayoutConstraint.- Returns:
- A new
ComponentStyleDelegatewith the provided layout constraints set to be later
-
alignmentX
Defines the alignment percentage alongside the X axis for a component (seeJComponent.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
ComponentStyleDelegatewith the provided alignment percentage alongside the X axis set to be later
-
alignmentY
Defines the alignment percentage alongside the Y axis for a component (seeJComponent.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
ComponentStyleDelegatewith the provided alignment percentage alongside the Y axis set to be later
-
getScale
public float getScale()A convenient delegate method toUI.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 theGraphics2DAPI.- 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 toUI.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 theGraphics2DAPI.- 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 customPainterimplementations (seepainter(UI.Layer, swingtree.api.Painter)) to scale anintvalue 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- Theintvalue to scale.- Returns:
- The scaled
intvalue.
-
scale
public float scale(float value) Use this method inside customPainterimplementations (seepainter(UI.Layer, swingtree.api.Painter)) to scale afloatvalue 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- Thefloatvalue to scale.- Returns:
- The scaled
floatvalue.
-
scale
public double scale(double value) Use this method inside customPainterimplementations (seepainter(UI.Layer, Painter)) to scale adoublevalue 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- Thedoublevalue to scale.- Returns:
- The scaled
doublevalue.
-
toString
-