diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/UIDefaultsLoader.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/UIDefaultsLoader.java index 26a5a6b7..da3557d5 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/UIDefaultsLoader.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/UIDefaultsLoader.java @@ -332,16 +332,17 @@ class UIDefaultsLoader private static Object parseBorder( String value, Function resolver, List addonClassLoaders ) { if( value.indexOf( ',' ) >= 0 ) { - // top,left,bottom,right[,lineColor] + // top,left,bottom,right[,lineColor[,lineThickness]] List parts = split( value, ',' ); Insets insets = parseInsets( value ); - ColorUIResource lineColor = (parts.size() == 5) + ColorUIResource lineColor = (parts.size() >= 5) ? (ColorUIResource) parseColorOrFunction( resolver.apply( parts.get( 4 ) ), resolver, true ) : null; + float lineThickness = (parts.size() >= 6) ? parseFloat( parts.get( 5 ), true ) : 1f; return (LazyValue) t -> { return (lineColor != null) - ? new FlatLineBorder( insets, lineColor ) + ? new FlatLineBorder( insets, lineColor, lineThickness ) : new FlatEmptyBorder( insets ); }; } else diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatLineBorder.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatLineBorder.java index 355bf01d..5af4c531 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatLineBorder.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatLineBorder.java @@ -26,9 +26,9 @@ import java.awt.Insets; /** * Line border for various components. * - * Paints a scaled 1px thick line around the component. - * The line thickness is not included in the border insets. - * The insets should be at least 1,1,1,1. + * Paints a scaled (usually 1px thick) line around the component. + * The line thickness is not added to the border insets. + * The insets should be at least have line thickness (usually 1,1,1,1). * * @author Karl Tauber */ @@ -36,10 +36,16 @@ public class FlatLineBorder extends FlatEmptyBorder { private final Color lineColor; + private final float lineThickness; public FlatLineBorder( Insets insets, Color lineColor ) { + this( insets, lineColor, 1f ); + } + + public FlatLineBorder( Insets insets, Color lineColor, float lineThickness ) { super( insets ); this.lineColor = lineColor; + this.lineThickness = lineThickness; } @Override @@ -48,7 +54,7 @@ public class FlatLineBorder try { FlatUIUtils.setRenderingHints( g2 ); g2.setColor( lineColor ); - FlatUIUtils.paintComponentBorder( g2, x, y, width, height, 0f, scale( 1f ), 0f ); + FlatUIUtils.paintComponentBorder( g2, x, y, width, height, 0f, scale( lineThickness ), 0f ); } finally { g2.dispose(); }