Package swingtree.style
Class StyleConf
java.lang.Object
swingtree.style.StyleConf
An immutable config container with cloning based update methods designed
for functional
JComponent
styling.
The styling in SwingTree is completely functional, meaning that changing a property
of a StyleConf
instance will always return a new StyleConf
instance with the
updated property.
Consider the following example demonstrating how a JPanel
is styled through the SwingTree
style API, which consists of a functional Styler
lambda that processes a
ComponentStyleDelegate
instance that internally assembles a StyleConf
object:
panel(FILL)
.withStyle( it -> it
.foundationColor(new Color(26,191,230))
.backgroundColor(new Color(255,255,255))
.paddingTop(30)
.paddingLeft(35)
.paddingRight(35)
.paddingBottom(30)
.borderRadius(25, 25)
.borderWidth(3)
.borderColor(new Color(0,102,255))
.shadowColor(new Color(64,64,64))
.shadowBlurRadius(6)
.shadowSpreadRadius(5)
.shadowInset(false)
)
This design is inspired by the CSS styling language and the use of immutable objects
is a key feature of the SwingTree API which makes it possible to safely compose
Styler
lambdas into a complex style pipeline
without having to worry about side effects.
See StyleSheet
for more information about
how this composition of styles is achieved in practice.-
Method Summary
Modifier and TypeMethodDescriptionbackgroundColor
(Color color) boolean
font()
foundationColor
(Color color) int
hashCode()
swingtree.style.LayoutConf
layout()
static StyleConf
none()
Exposes the "null object" pattern forStyleConf
instances.shadow()
Exposes the default shadow style configuration object.Internally, a style configuration consists of a set of layers defined by theUI.Layer
enum.toString()
-
Method Details
-
none
Exposes the "null object" pattern forStyleConf
instances. So the constant returned by this method is the default instance that represents the absence of a style.- Returns:
- The default style instance, representing the absence of a style.
-
layoutConstraint
-
layout
public swingtree.style.LayoutConf layout() -
shadow
Exposes the default shadow style configuration object.- Returns:
- The default shadow style.
-
shadow
Internally, a style configuration consists of a set of layers defined by theUI.Layer
enum. Using this method you can retrieve all shadow styles for a particular layer and with the provided name.- Parameters:
layer
- The layer to retrieve the shadow style from.shadowName
- The name of the shadow style to retrieve.- Returns:
- The shadow style with the provided name.
-
font
-
foundationColor
-
backgroundColor
-
hashCode
public int hashCode() -
equals
-
toString
-