Package swingtree.api
Interface Styler<C extends JComponent>
- Type Parameters:
C
- the type of theJComponent
that theComponentStyleDelegate
is delegating to.
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A
Note that all of this is done in a functional manner, so the original
This design makes the underlying style engine of SwingTree very flexible and scalable because it allows for the composition of styles and reuse of style logic across many components (see
Styler
is a function that takes a ComponentStyleDelegate
and then
transforms and returns it with some new style properties (see UIForAnySwing.withStyle(Styler)
). Note that all of this is done in a functional manner, so the original
ComponentStyleDelegate
as well as the delegated StyleConf
object is not modified
because ComponentStyleDelegate
is an immutable object. This design makes the underlying style engine of SwingTree very flexible and scalable because it allows for the composition of styles and reuse of style logic across many components (see
StyleSheet
for more advanced usage).-
Method Summary
Modifier and TypeMethodDescriptionstatic <C extends JComponent>
Styler<C>none()
AStyler
that does nothing, meaning it simply returns the givenComponentStyleDelegate
without applying any style to it.style
(ComponentStyleDelegate<C> delegate) Applies some style to the givenComponentStyleDelegate
and returns a newComponentStyleDelegate
that has the style applied (if any).
-
Method Details
-
none
AStyler
that does nothing, meaning it simply returns the givenComponentStyleDelegate
without applying any style to it.- Type Parameters:
C
- The type of theJComponent
that theComponentStyleDelegate
is delegating to.- Returns:
- A
Styler
that does nothing.
-
style
Applies some style to the givenComponentStyleDelegate
and returns a newComponentStyleDelegate
that has the style applied (if any).- Parameters:
delegate
- TheComponentStyleDelegate
to apply the style to.- Returns:
- A new
ComponentStyleDelegate
that has the style applied.
-
andThen
Returns a newStyler
that applies the style of thisStyler
and then applies the style of the givenStyler
.
This method is conceptually equivalent to theFunction.andThen(java.util.function.Function)
.
-