Class ComponentStyleDelegate<C extends JComponent>
- Type Parameters:
C
- The type ofJComponent
thisComponentStyleDelegate
is 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 StyleTrait
s, 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 newStyleConf
with the provided inner Background color defined by the supplied red, green and blue color channels in the form of doubles expected to be in the range of 0.0 to 1.0.backgroundColor
(double r, double g, double b, double a) Returns a newStyleConf
with the provided inner Background color defined by the supplied red, green, blue and alpha color channels in the form of doubles expected to be in the range of 0.0 to 1.0.backgroundColor
(Color color) Returns a newStyleConf
with the provided inner Background color.backgroundColor
(String colorString) Returns a newStyleConf
with the provided inner Background color in the form of a string.Returns a newStyleConf
with the provided border widths and border color.Returns a newStyleConf
with the provided border width and border color.Returns a newStyleConf
with the provided border width and border colors.Returns a newStyleConf
with the provided border width and border color in the form of a string.Returns a newStyleConf
with the provided border width and border colors in the form of strings.Returns a newStyleConf
with the provided width and color used to define the border for the specified edge of the component.Returns a newStyleConf
with the provided width and color string used to define the border for the specified edge of the component.borderColor
(Color color) Returns a newStyleConf
with the provided border color.borderColor
(String colorString) Returns an updatedStyleConf
with the provided border color in the form of a string.borderColors
(Color top, Color right, Color bottom, Color left) Returns a newStyleConf
with 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 newStyleConf
with the provided border colors in the form of strings.borderRadius
(double radius) Returns a newStyleConf
with the provided border radius set for all 4 corners of the target component.borderRadius
(double arcWidth, double arcHeight) Returns a newStyleConf
with 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 newStyleConf
with the provided border radius for the specified corner.borderRadiusAt
(UI.Corner corner, double arcWidth, double arcHeight) Returns a newStyleConf
with the provided border arc width and arc height for the specified corner.borderWidth
(double width) Returns a newStyleConf
with the provided border width.borderWidthAt
(UI.Edge edge, double width) Returns a newStyleConf
with the provided border width for the specified edge.borderWidths
(double topBottom, double leftRight) Returns a newStyleConf
with the provided top/bottom and left/right border widths.borderWidths
(double top, double right, double bottom, double left) Returns a newStyleConf
with the provided top, right, bottom and left border widths.final ComponentStyleDelegate<C>
componentFont
(Configurator<FontConf> fontStyler) Returns a newStyleConf
with the provided font style applied to the font property of the component (seeComponent.getFont()
).Defines the cursor type for thisJComponent
based on the providedCursor
value.Defines the cursor type for thisJComponent
based on the predefinedUI.Cursor
values.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 newStyleConf
where the font color is set to a color parsed from the provided string.fontBackgroundPaint
(@Nullable Paint paint) Updates this style delegate with the suppliedPaint
object used for the background of the font, which translates to theTextAttribute.BACKGROUND
attribute.fontBold
(boolean bold) Makes the font bold or not bold depending on the value of theisBold
parameter.Creates a newStyleConf
where the font color is set to a color parsed from the provided string.fontFamily
(String name) Returns a newStyleConf
with the provided font family name.fontItalic
(boolean italic) Makes the font italic or not italic depending on the value of theitalic
parameter.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 newStyleConf
where the font selection color is set to a color parsed from the provided string.fontSize
(int size) Returns a newStyleConf
with 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 thestrikeThrough
parameter.fontStyle
(UI.FontStyle style) Determines if the font should be plain, bold, italic or bold and italic based on the providedUI.FontStyle
parameter, which may beUI.FontStyle.PLAIN
,UI.FontStyle.BOLD
,UI.FontStyle.ITALIC
orUI.FontStyle.BOLD_ITALIC
.
Note that this will override any previous bold or italic settings.fontTransform
(@Nullable AffineTransform transform) TheAffineTransform
property 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 theunderline
parameter.fontWeight
(float weight) Use this to define the weight of the default font of the component.foregroundColor
(Color color) Returns a newStyleConf
with the provided foreground color.foregroundColor
(String colorString) Returns a newStyleConf
with the provided foreground color in the form of a string.foundationColor
(double r, double g, double b) Returns a newStyleConf
with the provided background foundation color defined by the supplied red, green and blue color channels in the form of doubles expected to be in the range of 0.0 to 1.0.foundationColor
(double r, double g, double b, double a) Returns a newStyleConf
with the provided background foundation color defined by the supplied red, green, blue and alpha color channels in the form of doubles expected to be in the range of 0.0 to 1.0.foundationColor
(Color color) Returns a newStyleConf
with the provided background foundation color.foundationColor
(String colorString) Returns a newStyleConf
with the provided background foundation color in the form of a string.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).gradient
(String shadeName, Configurator<GradientConf> styler) This method makes it possible to define multiple background gradient for a single component on theUI.Layer.BACKGROUND
layer, 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
(int height) Defines the height of thisJComponent
.Returns a newStyleConf
with the providedImageIcon
as the icon for the current component (seecomponent()
).icon
(ImageIcon icon, UI.FitComponent fit) Returns a newStyleConf
with the providedImageIcon
as 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 newStyleConf
with the providedIconDeclaration
as the source for the icon of the current component (seecomponent()
).icon
(IconDeclaration icon, UI.FitComponent fit) Returns a newStyleConf
with the providedIconDeclaration
as 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.BACKGROUND
layer, 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 theMigLayout
based layout constraints and column layout constraints of thisJComponent
in the form of aString
.Defines theMigLayout
based layout constraints column layout constraints and row layout constraints of thisJComponent
in the form of aString
.Use this to define the layout manager for thisJComponent
using aLayout
object.layout
(LayoutConstraint constraintAttr) Defines the layoutMigLayout
constraints for thisJComponent
in the form of aLayoutConstraint
(seeUILayoutConstants.FILL
,UILayoutConstants.FILL_X
,UILayoutConstants.FILL_Y
...).margin
(double margin) Creates a newStyleConf
with the provided margin distance for all sides of the component.margin
(double top, double right, double bottom, double left) Creates a newStyleConf
with the provided top, right, left and bottom margin distances.marginBottom
(double margin) Creates a newStyleConf
with the provided margin distance for the bottom side of the component.marginHorizontal
(double margin) Creates a newStyleConf
with the provided margin distance for the left and right sides of the component.marginLeft
(double margin) Creates a newStyleConf
with the provided margin distance for the left side of the component.marginRight
(double margin) Creates a newStyleConf
with the provided margin distance for the right side of the component.marginTop
(double margin) Creates a newStyleConf
with the provided margin distance for the top side of the component.marginVertical
(double margin) Creates a newStyleConf
with the provided margin distance for the top and bottom sides of the component.maxHeight
(int maxHeight) Defines the maximum height for thisJComponent
.maxSize
(int width, int height) Defines the maximumDimension
for thisJComponent
.Defines the maximumSize
for thisJComponent
.maxWidth
(int maxWidth) Defines the maximum width for thisJComponent
.minHeight
(int minHeight) Defines the minimum height for thisJComponent
.minSize
(int width, int height) Defines the minimumDimension
for thisJComponent
.Defines the minimum size for thisJComponent
in the form of aSize
object.minWidth
(int 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 newStyleConf
with the provided padding distance for all sides of the component.padding
(double top, double right, double bottom, double left) Creates a newStyleConf
with the provided top, right, left and bottom pad distances.paddingBottom
(double padding) Creates a newStyleConf
with the provided padding distance for the bottom side of the component.paddingHorizontal
(double padding) Creates a newStyleConf
with the provided padding distance for the left and right sides of the component.paddingLeft
(double padding) Creates a newStyleConf
with the provided padding distance for the left side of the component.paddingRight
(double padding) Creates a newStyleConf
with the provided padding distance for the right side of the component.paddingTop
(double padding) Creates a newStyleConf
with the provided padding distance for the top side of the component.paddingVertical
(double padding) Creates a newStyleConf
with the provided padding distance for the top and bottom sides of the component.Returns a newStyleConf
with the provided namedPainter
, which will be called using theGraphics2D
instance of the current component.Returns a newStyleConf
with the provided customPainter
, which will be called using theGraphics2D
of the current component.painter
(UI.Layer layer, UI.ComponentArea clipArea, String painterName, Painter painter) Returns a newStyleConf
with the provided namedPainter
, which will be called using theGraphics2D
instance of the current component.painter
(UI.Layer layer, UI.ComponentArea clipArea, Painter painter) Returns a newStyleConf
with the provided customPainter
, which will be called using theGraphics2D
of the current component.parent()
Exposes the parentContainer
of theJComponent
delegated by thisComponentStyleDelegate
through anOptional
in case the parent is null.parentFilter
(Configurator<FilterConf> filterStyler) Use this to peek at theJComponent
of thisComponentStyleDelegate
to perform some style-related component specific actions on it which are otherwise not found in theComponentStyleDelegate
API.prefHeight
(int preferredHeight) Defines the preferred height for thisJComponent
.prefSize
(int width, int height) Defines the preferredDimension
for thisJComponent
.Defines the preferredSize
for thisJComponent
.prefWidth
(int preferredWidth) Defines the preferred width for thisJComponent
.Allow for the specification of client properties on the styled component.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).double
scale
(double value) Use this method inside customPainter
implementations (seepainter(UI.Layer, Painter)
) to scale adouble
value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).float
scale
(float value) Use this method inside customPainter
implementations (seepainter(UI.Layer, swingtree.api.Painter)
) to scale afloat
value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).int
scale
(int value) Use this method inside customPainter
implementations (seepainter(UI.Layer, swingtree.api.Painter)
) to scale anint
value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).shadow
(String shadowName, Configurator<ShadowConf> styler) This method makes it possible to define multiple shadows for a single component on theUI.Layer.CONTENT
layer, 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 newStyleConf
with the provided shadow blur radius applied to all shadow configs.shadowColor
(double r, double g, double b) Returns a newStyleConf
with the provided shadow color defined by the supplied red, green and blue color channels in the form of doubles expected to be in the range of 0.0 to 1.0.shadowColor
(double r, double g, double b, double a) Returns a newStyleConf
with the provided shadow color defined by the supplied red, green, blue and alpha color channels in the form of doubles expected to be in the range of 0.0 to 1.0.shadowColor
(Color color) Returns a newStyleConf
with the provided shadow color applied to the default shadow.shadowColor
(String colorString) Returns a newStyleConf
with the provided shadow color in the form of a string.shadowHorizontalOffset
(double offset) Returns a newStyleConf
with 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 newStyleConf
with the provided horizontal and vertical shadow offset.shadowOffset
(double horizontalOffset, double verticalOffset) Returns a newStyleConf
with the provided shadow offset applied to all shadow configs.shadowSpreadRadius
(double radius) Returns a newStyleConf
with the provided shadow spread radius applied to all shadow configs.shadowVerticalOffset
(double offset) Returns a newStyleConf
with the provided vertical shadow offset applied to all shadow configs.size
(int width, int 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
(int width) Defines the width of thisJComponent
.
-
Method Details
-
component
Returns theJComponent
thisComponentStyleDelegate
is defining aStyleConf
for. This is useful if you want to make the styling of a component based on its state, like for example determining the background color of aJCheckBox
based on whether it is selected or not...- Returns:
- The
JComponent
thisComponentStyleDelegate
is for.
-
parent
Exposes the parentContainer
of theJComponent
delegated by thisComponentStyleDelegate
through anOptional
in case the parent is null. You may use this to make your styling dependent on the properties of the parent container.- Returns:
- An optional parent
Container
of theJComponent
thisComponentStyleDelegate
is for.
-
peek
Use this to peek at theJComponent
of thisComponentStyleDelegate
to perform some style-related component specific actions on it which are otherwise not found in theComponentStyleDelegate
API.- Parameters:
peeker
- APeeker
that takes theJComponent
of thisComponentStyleDelegate
- Returns:
- This
ComponentStyleDelegate
instance.
-
applyIf
Allows you to apply styles based on a condition. So if the first argument, the condition, is true, then it causes the suppliedStyler
to update the style, if however the condition is false, then the styler will simply be ignored and the style will not be updated.
Here a simple usage example:
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 aStyler
instead of a consumer, as the style API is based on immutable types whose updated results must be returned by the conditional scope.- Parameters:
condition
- The condition determining if the providedstyler
should be executed.styler
- A supplier for- Returns:
- This instance if the condition is false, or the supplied
styler
threw an exception, a new style delegate updated according to thestyler
.
-
margin
Creates a newStyleConf
with the provided top, right, left and bottom margin distances. It determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (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
ComponentStyleDelegate
with the provided padding distances.
-
margin
Creates a newStyleConf
with the provided margin distance for all sides of the component. The margin determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (seeborderWidth(double)
,backgroundColor(Color)
,shadowColor(Color)
).- Parameters:
margin
- The margin distance in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided margin distance.
-
marginTop
Creates a newStyleConf
with the provided margin distance for the top side of the component. The margin determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (seeborderWidth(double)
,backgroundColor(Color)
,shadowColor(Color)
).- Parameters:
margin
- The margin distance in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided margin distance.
-
marginRight
Creates a newStyleConf
with the provided margin distance for the right side of the component. The margin determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (seeborderWidth(double)
,backgroundColor(Color)
,shadowColor(Color)
).- Parameters:
margin
- The margin distance in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided margin distance.
-
marginBottom
Creates a newStyleConf
with the provided margin distance for the bottom side of the component. The margin determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (seeborderWidth(double)
,backgroundColor(Color)
,shadowColor(Color)
).- Parameters:
margin
- The margin distance in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided margin distance.
-
marginLeft
Creates a newStyleConf
with the provided margin distance for the left side of the component. The margin determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (seeborderWidth(double)
,backgroundColor(Color)
,shadowColor(Color)
).- Parameters:
margin
- The margin distance in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided margin distance.
-
marginVertical
Creates a newStyleConf
with the provided margin distance for the top and bottom sides of the component. The margin determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (seeborderWidth(double)
,backgroundColor(Color)
,shadowColor(Color)
).- Parameters:
margin
- The margin distance in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided margin distance.
-
marginHorizontal
Creates a newStyleConf
with the provided margin distance for the left and right sides of the component. The margin determines the amount of space between the component's outer bounds and the beginning of the inner border, background region and shadow frame (seeborderWidth(double)
,backgroundColor(Color)
,shadowColor(Color)
).- Parameters:
margin
- The margin distance in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided margin distance.
-
padding
Creates a newStyleConf
with the provided top, right, left and bottom pad distances. It determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. (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
ComponentStyleDelegate
with the provided padding distances.
-
padding
Creates a newStyleConf
with the provided padding distance for all sides of the component. It determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. (seeborderWidth(double)
,backgroundColor(Color)
,shadowColor(Color)
).- Parameters:
padding
- The padding distance in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided padding distance.
-
paddingTop
Creates a newStyleConf
with the provided padding distance for the top side of the component. The padding determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. (seeborderWidth(double)
,backgroundColor(Color)
,shadowColor(Color)
).- Parameters:
padding
- The padding distance in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided padding distance.
-
paddingRight
Creates a newStyleConf
with the provided padding distance for the right side of the component. The padding determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. of the inner border, background region and shadow frame (seeborderWidth(double)
,backgroundColor(Color)
,shadowColor(Color)
).- Parameters:
padding
- The padding distance in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided padding distance.
-
paddingBottom
Creates a newStyleConf
with the provided padding distance for the bottom side of the component. The padding determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. (seeborderWidth(double)
,backgroundColor(Color)
,shadowColor(Color)
).- Parameters:
padding
- The padding distance in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided padding distance.
-
paddingLeft
Creates a newStyleConf
with the provided padding distance for the left side of the component. The padding determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. (seeborderWidth(double)
,backgroundColor(Color)
,shadowColor(Color)
).- Parameters:
padding
- The padding distance in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided padding distance.
-
paddingVertical
Creates a newStyleConf
with the provided padding distance for the top and bottom sides of the component. The padding determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. (seeborderWidth(double)
,backgroundColor(Color)
,shadowColor(Color)
).- Parameters:
padding
- The padding distance in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided padding distance.
-
paddingHorizontal
Creates a newStyleConf
with the provided padding distance for the left and right sides of the component. The padding determines the amount of space between the inner bounds (the inner border, background region and shadow frame) and the component's content. (seeborderWidth(double)
,backgroundColor(Color)
,shadowColor(Color)
).- Parameters:
padding
- The padding distance in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided padding distance.
-
border
Returns a newStyleConf
with 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
ComponentStyleDelegate
with the provided border width and border color.
-
border
public ComponentStyleDelegate<C> border(double width, Color top, Color right, Color bottom, Color left) Returns a newStyleConf
with 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
ComponentStyleDelegate
with the provided border width and border colors.
-
border
public ComponentStyleDelegate<C> border(double top, double right, double bottom, double left, Color color) Returns a newStyleConf
with 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
ComponentStyleDelegate
with the provided border widths and border color.
-
border
Returns a newStyleConf
with the provided border width and border color in the form of a string. The string can be either a hex color string, a color name or a color constant from the system properties (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
ComponentStyleDelegate
with the provided border width and border color.
-
border
public ComponentStyleDelegate<C> border(double width, String top, String right, String bottom, String left) Returns a newStyleConf
with the provided border width and border colors in the form of strings. The strings can be either hex color strings, color names or color constants from the system properties. The border will be rendered with an inset space based on the padding defined by 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
ComponentStyleDelegate
with the provided border width and border colors.
-
borderWidth
Returns a newStyleConf
with the provided border width.Note that in order for the border to be visible you also have to specify it's color, which you can do through
borderColor(Color)
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
ComponentStyleDelegate
with the provided border width.
-
borderColors
Returns a newStyleConf
with the provided border colors, which are stored in the order of top, right, bottom, left. Note that a component border will be rendered with an inset space based on the padding defined by theStyleConf
.Instead of null, the
UI.Color.UNDEFINED
constant is used to indicate that a border color is not set.- Parameters:
top
- The color for the top part of the border.right
- The color for the right part of the border.bottom
- The color for the bottom part of the border.left
- The color for the left part of the border.- Returns:
- A new
ComponentStyleDelegate
with the provided border colors.
-
borderColors
Returns a newStyleConf
with the provided border colors in the form of strings. The strings can be either hex color strings, color names or color constants from the system properties (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
ComponentStyleDelegate
with the provided border colors.
-
borderWidthAt
Returns a newStyleConf
with the provided border width for the specified edge.Note that in order for the border to be visible you also have to specify it's color, which you can do through
borderColor(Color)
orborderColor(String)
.- Parameters:
edge
- The edge to set the border width for.width
- The border width in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided border width for the specified edge.
-
borderAt
Returns a newStyleConf
with the provided width and color used to define the border for the specified edge of the component. The border will be rendered with an inset space based on the padding defined by theStyleConf
.- Parameters:
edge
- The edge to set the border width and color for, you may useUI.Edge.EVERY
to set the same width and color for all edges.width
- The border width in pixels.color
- The border color.- Returns:
- A new
ComponentStyleDelegate
with the provided border width and color for the specified edge.
-
borderAt
Returns a newStyleConf
with the provided width and color string used to define the border for the specified edge of the component. The border will be rendered with an inset space based on the padding defined by 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.EVERY
to set the same width and color for all edges.width
- The border width in pixels.colorString
- The border color.- Returns:
- A new
ComponentStyleDelegate
with the provided border width and color for the specified edge.
-
borderWidths
Returns a newStyleConf
with the provided top, right, bottom and left border widths.The border widths are specified in the following order: top, right, bottom, left.
Example:
UI.panel().withStyle( it -> it.borderWidths(1, 2, 3, 4) )
Note that in order for the border to be visible you also have to specify it's color, which you can do through
borderColor(Color)
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
ComponentStyleDelegate
with the provided top, right, bottom and left border widths. - See Also:
-
borderWidths
Returns a newStyleConf
with the provided top/bottom and left/right border widths.Example:
UI.panel().withStyle( it -> it.borderWidths(1, 2) )
Note that in order for the border to be visible you also have to specify it's color, which you can do through
borderColor(Color)
orborderColor(String)
.- Parameters:
topBottom
- The top and bottom border width in pixels.leftRight
- The left and right border width in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided top/bottom and left/right border widths. - See Also:
-
borderColor
Returns a newStyleConf
with 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
ComponentStyleDelegate
with the provided border color.
-
borderColor
Returns an updatedStyleConf
with the provided border color in the form of a string. The string can be either a hex color string, a color name or a color constant from the system properties. The border will be rendered with an inset space based on the padding defined by theStyleConf
.- Parameters:
colorString
- The border color.- Returns:
- A new
ComponentStyleDelegate
with the provided border color.
-
borderRadius
Returns a newStyleConf
with the provided border radius set for all 4 corners of the target component. This will override both the arc width and arc height of each corner. The border will be rendered with an inset space based on the padding defined by thisStyleConf
.- Parameters:
radius
- The border radius in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided border radius.
-
borderRadius
Returns a newStyleConf
with the provided border arc width and arc height set for all 4 corners of the target component. Note that the border will be rendered with an inset space based on the padding defined by thisStyleConf
.- Parameters:
arcWidth
- The border arc width in pixels.arcHeight
- The border arc height in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided border arc width and arc height.
-
borderRadiusAt
public ComponentStyleDelegate<C> borderRadiusAt(UI.Corner corner, double arcWidth, double arcHeight) Returns a newStyleConf
with the provided border arc width and arc height for the specified corner. Note that the border will be rendered with an inset space based on the padding defined by 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
ComponentStyleDelegate
with the provided border arc width and arc height for the specified corner.
-
borderRadiusAt
Returns a newStyleConf
with the provided border radius for the specified corner. This will override both the arc width and arc height of the border. Note that the border will be rendered with an inset space based on the padding defined by thisStyleConf
.- Parameters:
corner
- The corner to apply the border radius to.radius
- The border radius in pixels.- Returns:
- A new
ComponentStyleDelegate
with the provided border radius for the specified corner.
-
icon
Returns a newStyleConf
with the providedImageIcon
as 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 variousAbstractButton
subclasses,JLabel
andJIcon
.- Parameters:
icon
- The icon.- Returns:
- A new
ComponentStyleDelegate
with the provided icon.
-
icon
Returns a newStyleConf
with the providedImageIcon
as 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 variousAbstractButton
subclasses,JLabel
andJIcon
.- Parameters:
icon
- The icon in the form of anImageIcon
.fit
- The fit mode for the icon (mostly intended forSvgIcon
).- Returns:
- A new
ComponentStyleDelegate
with the provided icon.
-
icon
Returns a newStyleConf
with the providedIconDeclaration
as 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 variousAbstractButton
subclasses,JLabel
andJIcon
.- Parameters:
icon
- The icon declaration, which will be resolved to anImageIcon
.- Returns:
- A new
ComponentStyleDelegate
with the provided icon.
-
icon
Returns a newStyleConf
with the providedIconDeclaration
as 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 variousAbstractButton
subclasses,JLabel
andJIcon
.- Parameters:
icon
- The icon declaration, which will be resolved to anImageIcon
.fit
- The fit mode for the icon (mostly intended forSvgIcon
).- Returns:
- A new
ComponentStyleDelegate
with the provided icon.
-
foundationColor
Returns a newStyleConf
with 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
ComponentStyleDelegate
with the provided background color.
-
foundationColor
Returns a newStyleConf
with the provided background foundation color in the form of a string. The string can be either a hex color string, a color name or a color constant from the system properties. The foundation color covers 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
ComponentStyleDelegate
with the provided background color.
-
foundationColor
Returns a newStyleConf
with the provided background foundation color defined by the supplied red, green and blue color channels in the form of doubles expected to be in the range of 0.0 to 1.0. The foundation color covers 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
ComponentStyleDelegate
with the provided background color.
-
foundationColor
Returns a newStyleConf
with the provided background foundation color defined by the supplied red, green, blue and alpha color channels in the form of doubles expected to be in the range of 0.0 to 1.0. The foundation color covers 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
ComponentStyleDelegate
with the provided background color.
-
backgroundColor
Returns a newStyleConf
with 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
ComponentStyleDelegate
with the provided inner background color.
-
backgroundColor
Returns a newStyleConf
with the provided inner Background color defined by the supplied red, green and blue color channels in the form of doubles expected to be in the range of 0.0 to 1.0. The background color covers 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
ComponentStyleDelegate
with the provided inner background color.
-
backgroundColor
Returns a newStyleConf
with the provided inner Background color defined by the supplied red, green, blue and alpha color channels in the form of doubles expected to be in the range of 0.0 to 1.0. The background color covers 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
ComponentStyleDelegate
with the provided inner background color.
-
backgroundColor
Returns a newStyleConf
with the provided inner Background color in the form of a string. The string can be either a hex color string, a color name or a color constant from the system properties. The background color covers 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
ComponentStyleDelegate
with the provided inner background color.
-
painter
Returns a newStyleConf
with the provided customPainter
, which will be called using theGraphics2D
of the current component. You may use this to render a custom background for the component.
Note that your custom painter will yield the best performance if they are value based in the sense that they 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.BACKGROUND
will be painted first, followed by theUI.Layer.CONTENT
and so on...
The following layers are available:painter
- A custom painter, which receives theGraphics2D
instance of the current component.- Returns:
- A new
ComponentStyleDelegate
with the provided background renderer.
-
painter
public ComponentStyleDelegate<C> painter(UI.Layer layer, UI.ComponentArea clipArea, Painter painter) Returns a newStyleConf
with the provided customPainter
, which will be called using theGraphics2D
of the current component. You may use this to render a custom background for the component on the specifiedUI.Layer
andUI.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.BACKGROUND
will be painted first, followed by theUI.Layer.CONTENT
and so on...
The following layers are available:clipArea
- The area to which the painting should be confined. Paint operations outside of this area will be clipped away. The following areas are available:painter
- A custom painter, which receives theGraphics2D
instance of the current component.- Returns:
- A new
ComponentStyleDelegate
with the provided background renderer.
-
painter
Returns a newStyleConf
with the provided namedPainter
, which will be called using theGraphics2D
instance of the current component. You may use this to render custom styles for the component...
The name can be used to overridePainter
instances with that same name or use a unique name to ensure that you style is not overridden by another style. This allows you to attach an arbitrary number of custom painters to a component.
Note that your custom painter will yield the best performance if they are value based in the sense that they 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.BACKGROUND
will be painted first, followed by theUI.Layer.CONTENT
and so on...
The following layers are available:painterName
- The name of the painter.painter
- The custom painter lambda to which theGraphics2D
instance of the current component will be passed.- Returns:
- A new
ComponentStyleDelegate
with the provided background renderer.
-
painter
public ComponentStyleDelegate<C> painter(UI.Layer layer, UI.ComponentArea clipArea, String painterName, Painter painter) Returns a newStyleConf
with the provided namedPainter
, which will be called using theGraphics2D
instance of the current component. You may use this to render custom styles for the component...
The name can be used to overridePainter
instances with that same name or use a unique name to ensure that you style is not overridden by another style. This allows you to attach an arbitrary number of custom painters to a component.
Note that your custom painter will yield the best performance if they are value based in the sense that they 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.BACKGROUND
will be painted first, followed by theUI.Layer.CONTENT
and so on...
The following layers are available:clipArea
- The area to which the painting should be confined. Paint operations outside of this area will be clipped away. The following areas are available:painterName
- The name of the painter.painter
- The custom painter lambda to which theGraphics2D
instance of the current component will be passed.- Returns:
- A new
ComponentStyleDelegate
with the provided background renderer.
-
foregroundColor
Returns a newStyleConf
with the provided foreground color.- Parameters:
color
- The foreground color.- Returns:
- A new
ComponentStyleDelegate
with the provided foreground color.
-
foregroundColor
Returns a newStyleConf
with the provided foreground color in the form of a string. The string can be either a hex color string, a color name or a color constant from the system properties.- Parameters:
colorString
- The foreground color.- Returns:
- A new
ComponentStyleDelegate
with the provided foreground color.
-
shadowHorizontalOffset
Returns a newStyleConf
with the provided horizontal shadow offset applied to all shadow configs. The shadow will be rendered with an inset space based on the padding defined by 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
ComponentStyleDelegate
with the provided horizontal shadow offset.
-
shadowVerticalOffset
Returns a newStyleConf
with the provided vertical shadow offset applied to all shadow configs. The shadow will be rendered with an inset space based on the padding defined by 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
ComponentStyleDelegate
with the provided vertical shadow offset.
-
shadowOffset
Returns a newStyleConf
with the provided shadow offset applied to all shadow configs. The shadow will be rendered with an inset space based on the padding defined by 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
ComponentStyleDelegate
with the provided shadow offset.
-
shadowOffset
Returns a newStyleConf
with 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
ComponentStyleDelegate
with the provided shadow offset.
-
shadowBlurRadius
Returns a newStyleConf
with the provided shadow blur radius applied to all shadow configs. The shadow will be rendered with an inset space based on the padding defined by 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
ComponentStyleDelegate
with the provided shadow blur radius.
-
shadowSpreadRadius
Returns a newStyleConf
with the provided shadow spread radius applied to all shadow configs. The shadow will be rendered with an inset space based on the padding defined by 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
ComponentStyleDelegate
with the provided shadow spread radius.
-
shadowColor
Returns a newStyleConf
with 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.CONTENT
layer, 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.CONTENT
layer).- Parameters:
color
- The shadow color.- Returns:
- A new
ComponentStyleDelegate
with the provided shadow color.
-
shadowColor
Returns a newStyleConf
with the provided shadow color in the form of a string. The string can be either a hex color string, a color name or a color constant from the system properties. Note that in order to see the shadow, you may also need to callshadowBlurRadius(double)
andshadowSpreadRadius(double)
.
The shadow will be rendered on theUI.Layer.CONTENT
layer, 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.CONTENT
layer).- Parameters:
colorString
- The shadow color.- Returns:
- A new
ComponentStyleDelegate
with the provided shadow color.
-
shadowColor
Returns a newStyleConf
with the provided shadow color defined by the supplied red, green and blue color channels in the form of doubles expected to be in the range of 0.0 to 1.0. Note that in order to see the shadow, you may also need to callshadowBlurRadius(double)
andshadowSpreadRadius(double)
.
The shadow will be rendered on theUI.Layer.CONTENT
layer, 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.CONTENT
layer).- Parameters:
r
- The red component of the shadow color in the range of 0.0 to 1.0.g
- The green component of the shadow color in the range of 0.0 to 1.0.b
- The blue component of the shadow color in the range of 0.0 to 1.0.- Returns:
- A new
ComponentStyleDelegate
with the provided shadow color.
-
shadowColor
Returns a newStyleConf
with the provided shadow color defined by the supplied red, green, blue and alpha color channels in the form of doubles expected to be in the range of 0.0 to 1.0. Note that in order to see the shadow, you may also need to callshadowBlurRadius(double)
andshadowSpreadRadius(double)
.
The shadow will be rendered on theUI.Layer.CONTENT
layer, 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.CONTENT
layer).- Parameters:
r
- The red component of the shadow color in the range of 0.0 to 1.0.g
- The green component of the shadow color in the range of 0.0 to 1.0.b
- The blue component of the shadow color in the range of 0.0 to 1.0.a
- The alpha component of the shadow color in the range of 0.0 to 1.0.- Returns:
- A new
ComponentStyleDelegate
with the provided shadow color.
-
shadowIsInset
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
ComponentStyleDelegate
with the provided shadow inset flag.
-
shadow
This method makes it possible to define multiple shadows for a single component on theUI.Layer.CONTENT
layer, by giving the shadow config a unique name. This is useful when you want to do advanced shadow effects, such as neumorphism a.k.a. soft UI.
Here is an example of how to use this method:
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 aShadowConf
and returns a newShadowConf
.- Returns:
- A new
ComponentStyleDelegate
with a named shadow defined by the provided styler lambda.
-
shadow
public ComponentStyleDelegate<C> shadow(UI.Layer layer, String shadowName, Configurator<ShadowConf> styler) This method makes it possible to define multiple shadows for a single component on a custom layer, by giving the shadow config a unique name. This is useful when you want to do advanced shadow effects, such as neumorphism a.k.a. soft UI.
Here is an example of how to use this method:
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.BACKGROUND
will be painted first, followed by theUI.Layer.CONTENT
and so on...
The following layers are available:shadowName
- The name of the shadow.styler
- A function that takes aShadowConf
and returns a newShadowConf
.- Returns:
- A new
ComponentStyleDelegate
with 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.BACKGROUND
layer, by giving the gradient config a unique name. This is useful when you want to do advanced background effects, such as neumorphism a.k.a. soft UI.
Here is an example of how to use this method:
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 aGradientConf
and returns a newGradientConf
.- Returns:
- A new
ComponentStyleDelegate
with a named background shade defined by the provided styler lambda.
-
gradient
public ComponentStyleDelegate<C> gradient(UI.Layer layer, String shadeName, Configurator<GradientConf> styler) This method makes it possible to define multiple background gradient for a single component on a particular layer, by giving the gradient config a unique name. This is useful when you want to do advanced background effects, such as neumorphism a.k.a. soft UI.
Here is an example of how to use this method:
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 aGradientConf
and returns a newGradientConf
.- Returns:
- A new
ComponentStyleDelegate
with 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.BACKGROUND
and the name being the "default" style name- Parameters:
styler
- A function that takes aGradientConf
and returns a newGradientConf
.- Returns:
- A new
ComponentStyleDelegate
with 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 aGradientConf
and returns a newGradientConf
.- Returns:
- A new
ComponentStyleDelegate
with 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 aNoiseConf
and returns a newNoiseConf
.- Returns:
- A new
ComponentStyleDelegate
with a background noise defined by the provided styler lambda.
-
noise
public ComponentStyleDelegate<C> noise(UI.Layer layer, String noiseName, Configurator<NoiseConf> styler) This method makes it possible to define a background noise for your components. This is useful when you want to give component surfaces some naturally looking texture or special effects.
Here is an example of how to use the method:UI.panel() .withStyle( it -> it .noise(UI.Layer.BACKGROUND, "my-noise" conf -> conf .scale(2, 3).rotation(45) .colors(Color.BLACK, Color.WHITE) .offset(64,85) ) )
- Parameters:
layer
- The layer on which the noise should be rendered.styler
- A function that takes aNoiseConf
and returns a newNoiseConf
.- Returns:
- A new
ComponentStyleDelegate
with a background noise defined by the provided styler lambda.
-
noise
This method makes it possible to define a background noise for your components. This is useful when you want to give component surfaces some naturally looking texture or special effects.
Here is an example of how to use this method:
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.BACKGROUND
and the name being the "default" style name.- Parameters:
styler
- A function that takes aNoiseConf
and returns a newNoiseConf
.- Returns:
- A new
ComponentStyleDelegate
with 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.BACKGROUND
layer, by giving the background config a unique name. This is useful when you want to do advanced backgrounds displaying multiple images on top of each other.
Here is an example of how to use this method:
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 aImageConf
and returns a newImageConf
.- Returns:
- A new
ComponentStyleDelegate
with a named background image defined by the provided styler lambda.
-
image
public ComponentStyleDelegate<C> image(UI.Layer layer, String imageName, Configurator<ImageConf> styler) This method makes it possible to define multiple background styles for a single component rendered on a particular layer, by giving the background config a unique name. This is useful when you want to do advanced layer backgrounds displaying multiple images on top of each other.
Here is an example of how to use this method:
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 aImageConf
and returns a newImageConf
.- Returns:
- A new
ComponentStyleDelegate
with a named background image defined by the provided styler lambda.
-
image
Allows for the rendering of a background image on your components. This is useful when you want to do advanced backgrounds displaying multiple images on top of each other.
Here is an example of how to use this method:
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.BACKGROUND
and the name being the "default" style name.- Parameters:
styler
- A function that takes aImageConf
and returns a newImageConf
.- Returns:
- A new
ComponentStyleDelegate
with 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 aImageConf
and returns a newImageConf
.- Returns:
- A new
ComponentStyleDelegate
with a background image defined by the provided styler lambda.
-
text
Returns an updatedStyleConf
with a named text style configurator for the defaultTextConf
of the component.
The sub-style exposed by this method adds support for text rendering to all components not just text components.
If you only want to style 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:
styler
- A configurator function that takes aTextConf
and returns an updatedTextConf
. The configurator function is called with the default text style of the component.- Returns:
- A new
ComponentStyleDelegate
with the provided text style. Each unique name creates an additional text style for the component. - Throws:
NullPointerException
- If the provided styler or textName isnull
.- See Also:
-
text
public ComponentStyleDelegate<C> text(UI.Layer layer, String textName, Configurator<TextConf> styler) Returns an updatedStyleConf
with the provided named text style configurator for the defaultTextConf
of the component.
The sub-style exposed by this method adds support for text rendering to all components not just text components.
If you only want to style 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 aTextConf
and returns an updatedTextConf
. The configurator function is called with the default text style of the component.- Returns:
- A new
ComponentStyleDelegate
with the provided text style. - Throws:
NullPointerException
- If the provided styler or textName isnull
.- See Also:
-
text
Returns an updatedStyleConf
with the provided text style configurator for the defaultTextConf
of the component.
The sub-style exposed by this method adds support for text rendering to all components not just text components.
If you only want to style theComponent.getFont()
property of the component, you can usecomponentFont(Configurator)
instead.- Parameters:
styler
- A configurator function that takes aTextConf
and returns an updatedTextConf
. The configurator function is called with the default text style of the component.- Returns:
- A new
ComponentStyleDelegate
with the provided text style. - Throws:
NullPointerException
- If the provided styler 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.
Anull
reference 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
ComponentStyleDelegate
with the provided client property. - Throws:
NullPointerException
- If the value isnull
! (Use""
to remove a property)- See Also:
-
parentFilter
-
componentFont
Returns a newStyleConf
with 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 aFontConf
and returns a newFontConf
that is exclusively applied to the font property of the component.- Returns:
- A new
ComponentStyleDelegate
with the provided font style applied to the font property of the component.
-
font
Returns a newStyleConf
with the provided font name and size.
Note that the font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (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
ComponentStyleDelegate
with the provided font name and size.
-
fontFamily
Returns a newStyleConf
with the provided font family name. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (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
ComponentStyleDelegate
with the provided font name.
-
font
Returns a newStyleConf
with 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
ComponentStyleDelegate
with the providedFont
. - Throws:
NullPointerException
- If the font isnull
. UseUI.Font.UNDEFINED
to remove the font style.
-
fontSize
Returns a newStyleConf
with the provided font size. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (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
ComponentStyleDelegate
with the provided font size.
-
fontBold
Makes the font bold or not bold depending on the value of theisBold
parameter. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (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
ComponentStyleDelegate
with the provided font boldness.
-
fontItalic
Makes the font italic or not italic depending on the value of theitalic
parameter. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (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
ComponentStyleDelegate
with the provided font italicness.
-
fontStyle
Determines if the font should be plain, bold, italic or bold and italic based on the providedUI.FontStyle
parameter, which may beUI.FontStyle.PLAIN
,UI.FontStyle.BOLD
,UI.FontStyle.ITALIC
orUI.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
ComponentStyleDelegate
with the provided font style.
-
fontUnderline
Makes the font underlined or not underlined depending on the value of theunderline
parameter. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (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
ComponentStyleDelegate
with the provided font underlinedness.
-
fontStrikeThrough
Makes the font struck through or not struck through depending on the value of thestrikeThrough
parameter. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (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
ComponentStyleDelegate
with the provided font struck throughness.
-
fontColor
Creates a newStyleConf
where 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
ComponentStyleDelegate
with the provided font color. - Throws:
NullPointerException
- If the color isnull
. UseUI.Color.UNDEFINED
to remove the font color style.
-
fontColor
Creates a newStyleConf
where the font color is set to a color parsed from the provided string. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (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
- TheColor
as a string.- Returns:
- A new
ComponentStyleDelegate
with the provided font color.
-
fontBackgroundColor
Creates a newStyleConf
where 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
ComponentStyleDelegate
with the provided font background color. - Throws:
NullPointerException
- If the color isnull
. UseUI.Color.UNDEFINED
to remove the font background color style.
-
fontBackgroundColor
Creates a newStyleConf
where the font color is set to a color parsed from the provided string. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (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
- TheColor
as a string.- Returns:
- A new
ComponentStyleDelegate
with the provided font color.
-
fontSelectionColor
Creates a newStyleConf
where 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
ComponentStyleDelegate
with the provided font selection color. - Throws:
NullPointerException
- If the color isnull
. UseUI.Color.UNDEFINED
to remove the font selection color style.
-
fontSelectionColor
Creates a newStyleConf
where the font selection color is set to a color parsed from the provided string. Note that font styles will only apply if the component that is being rendered also supports displaying text, or has a custom text style (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
- TheColor
as a string.- Returns:
- A new
ComponentStyleDelegate
with the provided font selection color.
-
fontTransform
TheAffineTransform
property of a font defines how the font is rotated, scaled, skewed or translated. This method allows you to apply a customAffineTransform
to the fonts of the component.- Parameters:
transform
- TheAffineTransform
to apply to the font.- Returns:
- A new
ComponentStyleDelegate
with 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
- ThePaint
to use for the foreground of the font, which translates to theTextAttribute.FOREGROUND
attribute.- Returns:
- A new
ComponentStyleDelegate
with the provided font paint.
-
fontBackgroundPaint
Updates this style delegate with the suppliedPaint
object used for the background of the font, which translates to theTextAttribute.BACKGROUND
attribute.- Parameters:
paint
- ThePaint
to use for the background of the font, which translates to theTextAttribute.BACKGROUND
attribute.- Returns:
- A new
ComponentStyleDelegate
with 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
ComponentStyleDelegate
with the provided font weight.
-
fontSpacing
The font spacing, which is also known as tracking, is the space between characters in a font. SeeTextAttribute.TRACKING
for more information.- Parameters:
spacing
- The spacing of the default font of the component, which translates to theTextAttribute.TRACKING
attribute.- Returns:
- A new
ComponentStyleDelegate
with 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.HorizontalAlignment
for more information.- Returns:
- A new
ComponentStyleDelegate
with the provided font alignment. - Throws:
NullPointerException
- If the alignment isnull
. UseUI.HorizontalAlignment.UNDEFINED
to 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.VerticalAlignment
for more information.- Returns:
- A new
ComponentStyleDelegate
with the provided font alignment. throws NullPointerException If the alignment isnull
. UseUI.VerticalAlignment.UNDEFINED
to 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.Alignment
for more information.- Returns:
- A new
ComponentStyleDelegate
with the provided font alignment. throws NullPointerException If the alignment isnull
. UseUI.Alignment.UNDEFINED
to remove the font alignment style.
-
minSize
Defines the minimumDimension
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:
width
- The minimum width.height
- The minimum height.- Returns:
- A new
ComponentStyleDelegate
with the provided minimumDimension
set to be later applied to the underlying component when the finalStyleConf
is applied.
-
minSize
Defines the minimum size for thisJComponent
in the form of aSize
object.
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
ComponentStyleDelegate
with the provided minimumSize
set to be later applied to the underlying component when the finalStyleConf
is 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
ComponentStyleDelegate
with the provided minimum width set to be later applied to the underlying component when the finalStyleConf
is 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
ComponentStyleDelegate
with the provided minimum height set to be later applied to the underlying component when the finalStyleConf
is applied.
-
maxSize
Defines the maximumDimension
for thisJComponent
.
This ultimately translates toJComponent.setMaximumSize(Dimension)
on the underlying component.
The passedDimension
will be applied when all the other styles are applied and rendered.- Parameters:
width
- The maximum width.height
- The maximum height.- Returns:
- A new
ComponentStyleDelegate
with the provided maximumDimension
set to be later applied to the underlying component when the finalStyleConf
is applied.
-
maxSize
Defines the maximumSize
for thisJComponent
.
This ultimately translates toJComponent.setMaximumSize(Dimension)
on the underlying component.
The passedSize
will be applied when all the other styles are applied and rendered.- Parameters:
maxSize
- The maximumSize
.- Returns:
- A new
ComponentStyleDelegate
with the provided maximumSize
set to be later applied to the underlying component when the finalStyleConf
is 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
ComponentStyleDelegate
with the provided maximum width set to be later applied to the underlying component when the finalStyleConf
is 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
ComponentStyleDelegate
with the provided maximum height set to be later applied to the underlying component when the finalStyleConf
is applied.
-
prefSize
Defines the preferredSize
for thisJComponent
.
This ultimately translates toJComponent.setPreferredSize(Dimension)
on the underlying component.
The passedSize
will be applied when all the other styles are applied and rendered.- Parameters:
preferredSize
- The preferredSize
.- Returns:
- A new
ComponentStyleDelegate
with the provided preferredSize
set to be later applied to the underlying component when the finalStyleConf
is applied.
-
prefSize
Defines the preferredDimension
for thisJComponent
.
This ultimately translates toJComponent.setPreferredSize(Dimension)
on the underlying component.
The passedDimension
will be applied when all the other styles are applied and rendered.- Parameters:
width
- The preferred width.height
- The preferred height.- Returns:
- A new
ComponentStyleDelegate
with the provided preferredDimension
set to be later applied to the underlying component when the finalStyleConf
is 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
ComponentStyleDelegate
with the provided preferred width set to be later applied to the underlying component when the finalStyleConf
is 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
ComponentStyleDelegate
with the provided preferred height set to be later applied to the underlying component when the finalStyleConf
is 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
ComponentStyleDelegate
with the providedSize
(width and height) set to be later applied to the underlying component when the finalStyleConf
is 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
ComponentStyleDelegate
with the provided size (width and height)Dimension
set to be later applied to the underlying component when the finalStyleConf
is applied.
-
width
Defines the width of thisJComponent
.
This ultimately translates toComponent.setSize(Dimension)
on the underlying component.- Parameters:
width
- The width.- Returns:
- A new
ComponentStyleDelegate
with the provided width set to be later applied to the underlying component when the finalStyleConf
is applied.
-
height
Defines the height of thisJComponent
.
This ultimately translates toComponent.setSize(Dimension)
on the underlying component.- Parameters:
height
- The height.- Returns:
- A new
ComponentStyleDelegate
with the provided height set to be later applied to the underlying component when the finalStyleConf
is applied.
-
cursor
Defines the cursor type for thisJComponent
based on the predefinedUI.Cursor
values.
If you want to specify a custom cursor implementation, usecursor(Cursor)
instead.- Parameters:
cursor
- TheUI.Cursor
value.- Returns:
- A new
ComponentStyleDelegate
with the provided cursor type set to be later
-
cursor
Defines the cursor type for thisJComponent
based on the providedCursor
value.
Use this method if you want to specify a custom cursor implementation, in case you merely want to pick one of the many predefinedUI.Cursor
values, usecursor(UI.Cursor)
instead.- Parameters:
cursor
- TheCursor
value.- Returns:
- A new
ComponentStyleDelegate
with 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 AWTComponentOrientation
constants.- Returns:
- A new
ComponentStyleDelegate
with the providedUI.ComponentOrientation
set to be later applied to the underlying component when the finalStyleConf
is applied.
-
layout
Use this to define the layout manager for thisJComponent
using aLayout
object.
Checkout the factory methods inLayout
for creating different types of layout managers likeLayout.flow()
,Layout.mig(String)
orLayout.grid(int, int)
.- Parameters:
installer
- TheLayout
to use for installing the layout.- Returns:
- A new
ComponentStyleDelegate
with the providedLayout
set to be later
-
layout
Defines the layoutMigLayout
constraints for thisJComponent
in 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 aMigLayout
on the component if it does not already have one.- Parameters:
constraints
- The layout constraints as aString
.- Returns:
- A new
ComponentStyleDelegate
with the provided layout constraints set to be later
-
layout
Defines theMigLayout
based layout constraints and column layout constraints of thisJComponent
in 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 aMigLayout
on 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
ComponentStyleDelegate
with the provided layout constraints set to be later
-
layout
public ComponentStyleDelegate<C> layout(String constraints, String columnConstraints, String rowConstraints) Defines theMigLayout
based layout constraints column layout constraints and row layout constraints of thisJComponent
in 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 aMigLayout
on 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
ComponentStyleDelegate
with 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 aMigLayout
on the parent component if it does not already have one.- Parameters:
constraints
- The component constraints as aString
.- Returns:
- A new
ComponentStyleDelegate
with the provided component constraints set to be later
-
layout
Defines the layoutMigLayout
constraints for thisJComponent
in 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 aMigLayout
on the component if it does not already have one.- Parameters:
constraintAttr
- The layout constraints as aLayoutConstraint
.- Returns:
- A new
ComponentStyleDelegate
with 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
ComponentStyleDelegate
with 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
ComponentStyleDelegate
with 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 theGraphics2D
API.- Returns:
- The current UI scale factor, which is used to scale the UI for high resolution displays (high dots-per-inch, or DPI).
-
scale
public float scale()A convenient delegate method 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 theGraphics2D
API.- Returns:
- The current UI scale factor, which is used to scale the UI for high resolution displays (high dots-per-inch, or DPI).
-
scale
public int scale(int value) Use this method inside customPainter
implementations (seepainter(UI.Layer, swingtree.api.Painter)
) to scale anint
value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).- Parameters:
value
- Theint
value to scale.- Returns:
- The scaled
int
value.
-
scale
public float scale(float value) Use this method inside customPainter
implementations (seepainter(UI.Layer, swingtree.api.Painter)
) to scale afloat
value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).- Parameters:
value
- Thefloat
value to scale.- Returns:
- The scaled
float
value.
-
scale
public double scale(double value) Use this method inside customPainter
implementations (seepainter(UI.Layer, Painter)
) to scale adouble
value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).- Parameters:
value
- Thedouble
value to scale.- Returns:
- The scaled
double
value.
-
toString
-