mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
Styling: Extras: add styleClass getter and setter to component classes
This commit is contained in:
@@ -34,6 +34,8 @@ public interface FlatStyleableComponent
|
|||||||
/**
|
/**
|
||||||
* Returns the style of a component as String in CSS syntax ("key1: value1; key2: value2; ...")
|
* Returns the style of a component as String in CSS syntax ("key1: value1; key2: value2; ...")
|
||||||
* or {@code null} if no style has been assigned.
|
* or {@code null} if no style has been assigned.
|
||||||
|
*
|
||||||
|
* @see FlatClientProperties#STYLE
|
||||||
*/
|
*/
|
||||||
default String getStyle() {
|
default String getStyle() {
|
||||||
return (String) getClientProperty( FlatClientProperties.STYLE );
|
return (String) getClientProperty( FlatClientProperties.STYLE );
|
||||||
@@ -48,6 +50,8 @@ public interface FlatStyleableComponent
|
|||||||
* The syntax of the CSS values is the same as used in FlatLaf properties files
|
* The syntax of the CSS values is the same as used in FlatLaf properties files
|
||||||
* (<a href="https://www.formdev.com/flatlaf/properties-files/">https://www.formdev.com/flatlaf/properties-files/</a>),
|
* (<a href="https://www.formdev.com/flatlaf/properties-files/">https://www.formdev.com/flatlaf/properties-files/</a>),
|
||||||
* but some features are not supported (e.g. variables).
|
* but some features are not supported (e.g. variables).
|
||||||
|
*
|
||||||
|
* @see FlatClientProperties#STYLE
|
||||||
*/
|
*/
|
||||||
default void setStyle( String style ) {
|
default void setStyle( String style ) {
|
||||||
putClientProperty( FlatClientProperties.STYLE, style );
|
putClientProperty( FlatClientProperties.STYLE, style );
|
||||||
@@ -57,6 +61,8 @@ public interface FlatStyleableComponent
|
|||||||
/**
|
/**
|
||||||
* Returns the style of a component as {@link java.util.Map}<String, Object>
|
* Returns the style of a component as {@link java.util.Map}<String, Object>
|
||||||
* or {@code null} if no style has been assigned.
|
* or {@code null} if no style has been assigned.
|
||||||
|
*
|
||||||
|
* @see FlatClientProperties#STYLE
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings( "unchecked" )
|
||||||
default Map<String, Object> getStyleMap() {
|
default Map<String, Object> getStyleMap() {
|
||||||
@@ -70,12 +76,34 @@ public interface FlatStyleableComponent
|
|||||||
* E.g. for UI default {@code Slider.thumbSize} use key {@code thumbSize}.
|
* E.g. for UI default {@code Slider.thumbSize} use key {@code thumbSize}.
|
||||||
* <p>
|
* <p>
|
||||||
* The values are not parsed from a string. They must be binary.
|
* The values are not parsed from a string. They must be binary.
|
||||||
|
*
|
||||||
|
* @see FlatClientProperties#STYLE
|
||||||
*/
|
*/
|
||||||
default void setStyleMap( Map<String, Object> styleMap ) {
|
default void setStyleMap( Map<String, Object> styleMap ) {
|
||||||
putClientProperty( FlatClientProperties.STYLE, styleMap );
|
putClientProperty( FlatClientProperties.STYLE, styleMap );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the style class(es) of a component (separated by space characters)
|
||||||
|
* or {@code null} if no style class has been assigned.
|
||||||
|
*
|
||||||
|
* @see FlatClientProperties#STYLE_CLASS
|
||||||
|
*/
|
||||||
|
default String getStyleClass() {
|
||||||
|
return (String) getClientProperty( FlatClientProperties.STYLE_CLASS );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the style class(es) of a component (separated by space characters).
|
||||||
|
*
|
||||||
|
* @see FlatClientProperties#STYLE_CLASS
|
||||||
|
*/
|
||||||
|
default void setStyleClass( String styleClass ) {
|
||||||
|
putClientProperty( FlatClientProperties.STYLE_CLASS, styleClass );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides {@link JComponent#getClientProperty(Object)}.
|
* Overrides {@link JComponent#getClientProperty(Object)}.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user