diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e2a4d94..519bfd2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,12 @@ FlatLaf Change Log - arrow keys move focus within toolbar - tab-key moves focus out of toolbar - if moving focus into the toolbar, focus recently focused toolbar button +- ComboBox, Spinner, TextField and subclasses: Support specifying width of + border (see UI value `Component.borderWidth`). +- CheckBox and RadioButton: Support specifying width of icon border (see UI + value `CheckBox.icon.borderWidth`). +- Slider: Support specifying width of thumb border (see UI value + `Slider.thumbBorderWidth`). - Added more color functions to class `ColorFunctions` for easy use in applications: `lighten()`, `darken()`, `saturate()`, `desaturate()`, `spin()`, `tint()`, `shade()` and `luma()`. diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatCheckBoxIcon.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatCheckBoxIcon.java index 4a5800fa..7c467a53 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatCheckBoxIcon.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatCheckBoxIcon.java @@ -34,15 +34,19 @@ import com.formdev.flatlaf.ui.FlatUIUtils; /** * Icon for {@link javax.swing.JCheckBox}. - * - * Note: If Component.focusWidth is greater than zero, then the outline focus border + *
+ * Note: + * If Component.focusWidth is greater than zero, then the outer focus border * is painted outside of the icon bounds. Make sure that the checkbox * has margins, which are equal or greater than focusWidth. * - * @uiDefault CheckBox.icon.style String optional; "outline"/null (default) or "filled" + * @uiDefault CheckBox.icon.style String optional; "outlined"/null (default) or "filled" * @uiDefault Component.focusWidth int + * @uiDefault Component.borderWidth int * @uiDefault Component.focusColor Color * @uiDefault CheckBox.icon.focusWidth int optional; defaults to Component.focusWidth + * @uiDefault CheckBox.icon.borderWidth int or float optional; defaults to Component.borderWidth + * * @uiDefault CheckBox.icon.focusColor Color optional; defaults to Component.focusColor * @uiDefault CheckBox.icon.borderColor Color * @uiDefault CheckBox.icon.background Color @@ -74,6 +78,8 @@ public class FlatCheckBoxIcon UIManager.getInt( "Component.focusWidth" ), style ); @Styleable protected Color focusColor = FlatUIUtils.getUIColor( "CheckBox.icon.focusColor", UIManager.getColor( "Component.focusColor" ) ); + /** @since 2 */ @Styleable protected float borderWidth = getUIFloat( "CheckBox.icon.borderWidth", + FlatUIUtils.getUIFloat( "Component.borderWidth", 1 ), style ); @Styleable protected int arc = FlatUIUtils.getUIInt( "CheckBox.arc", 2 ); // enabled @@ -115,13 +121,23 @@ public class FlatCheckBoxIcon protected static int getUIInt( String key, int defaultValue, String style ) { if( style != null ) { - Object value = UIManager.get( styleKey( key, style ) ); - if( value instanceof Integer ) - return (Integer) value; + int value = FlatUIUtils.getUIInt( styleKey( key, style ), Integer.MIN_VALUE ); + if( value != Integer.MIN_VALUE ) + return value; } return FlatUIUtils.getUIInt( key, defaultValue ); } + /** @since 2 */ + protected static float getUIFloat( String key, float defaultValue, String style ) { + if( style != null ) { + float value = FlatUIUtils.getUIFloat( styleKey( key, style ), Float.MIN_VALUE ); + if( value != Float.MIN_VALUE ) + return value; + } + return FlatUIUtils.getUIFloat( key, defaultValue ); + } + private static String styleKey( String key, String style ) { return key.replace( ".icon.", ".icon[" + style + "]." ); } @@ -180,7 +196,7 @@ public class FlatCheckBoxIcon } protected void paintFocusBorder( Component c, Graphics2D g ) { - // the outline focus border is painted outside of the icon + // the outer focus border is painted outside of the icon int wh = ICON_SIZE - 1 + (focusWidth * 2); int arcwh = arc + (focusWidth * 2); g.fillRoundRect( -focusWidth + 1, -focusWidth, wh, wh, arcwh, arcwh ); @@ -192,8 +208,10 @@ public class FlatCheckBoxIcon } protected void paintBackground( Component c, Graphics2D g ) { + float xy = borderWidth; + float wh = 14 - (borderWidth * 2); int arcwh = arc - 1; - g.fillRoundRect( 2, 1, 12, 12, arcwh, arcwh ); + g.fill( new RoundRectangle2D.Float( 1 + xy, xy, wh, wh, arcwh, arcwh ) ); } protected void paintCheckmark( Component c, Graphics2D g ) { diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatRadioButtonIcon.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatRadioButtonIcon.java index 381d2910..14ad53df 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatRadioButtonIcon.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatRadioButtonIcon.java @@ -23,23 +23,24 @@ import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; /** * Icon for {@link javax.swing.JRadioButton}. - * - * Note: If Component.focusWidth is greater than zero, then the outline focus border + *
+ * Note: + * If Component.focusWidth is greater than zero, then the outer focus border * is painted outside of the icon bounds. Make sure that the radiobutton * has margins, which are equal or greater than focusWidth. * - * @uiDefault RadioButton.icon.centerDiameter int + * @uiDefault RadioButton.icon.centerDiameter int or float * * @author Karl Tauber */ public class FlatRadioButtonIcon extends FlatCheckBoxIcon { - @Styleable protected int centerDiameter = getUIInt( "RadioButton.icon.centerDiameter", 8, style ); + @Styleable protected float centerDiameter = getUIFloat( "RadioButton.icon.centerDiameter", 8, style ); @Override protected void paintFocusBorder( Component c, Graphics2D g ) { - // the outline focus border is painted outside of the icon + // the outer focus border is painted outside of the icon int wh = ICON_SIZE + (focusWidth * 2); g.fillOval( -focusWidth, -focusWidth, wh, wh ); } @@ -51,7 +52,9 @@ public class FlatRadioButtonIcon @Override protected void paintBackground( Component c, Graphics2D g ) { - g.fillOval( 1, 1, 13, 13 ); + float xy = borderWidth; + float wh = 15 - (borderWidth * 2); + g.fill( new Ellipse2D.Float( xy, xy, wh, wh ) ); } @Override diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatBorder.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatBorder.java index 276c5061..636ada15 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatBorder.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatBorder.java @@ -38,17 +38,19 @@ import com.formdev.flatlaf.util.DerivedColor; /** * Border for various components (e.g. {@link javax.swing.JTextField}). - * + *
* There is empty space around the component border, if Component.focusWidth is greater than zero, * which is used to paint outer focus border. - * + *
* Because there is empty space (if outer focus border is not painted),
* UI delegates that use this border (or subclasses) must invoke
- * {@link FlatUIUtils#paintParentBackground} to paint the empty space correctly.
+ * {@link FlatUIUtils#paintParentBackground} to fill the empty space correctly.
*
* @uiDefault Component.focusWidth int
* @uiDefault Component.innerFocusWidth int or float
* @uiDefault Component.innerOutlineWidth int or float
+ * @uiDefault Component.borderWidth int or float
+ *
* @uiDefault Component.focusColor Color
* @uiDefault Component.borderColor Color
* @uiDefault Component.disabledBorderColor Color
@@ -69,6 +71,8 @@ public class FlatBorder
@Styleable protected int focusWidth = UIManager.getInt( "Component.focusWidth" );
@Styleable protected float innerFocusWidth = FlatUIUtils.getUIFloat( "Component.innerFocusWidth", 0 );
@Styleable protected float innerOutlineWidth = FlatUIUtils.getUIFloat( "Component.innerOutlineWidth", 0 );
+ /** @since 2 */ @Styleable protected float borderWidth = FlatUIUtils.getUIFloat( "Component.borderWidth", 1 );
+
@Styleable protected Color focusColor = UIManager.getColor( "Component.focusColor" );
@Styleable protected Color borderColor = UIManager.getColor( "Component.borderColor" );
@Styleable protected Color disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
@@ -105,7 +109,7 @@ public class FlatBorder
float focusWidth = scale( (float) getFocusWidth( c ) );
float focusInnerWidth = 0;
- float borderWidth = scale( (float) getBorderWidth( c ) );
+ float borderWidth = scale( getBorderWidth( c ) );
float arc = scale( (float) getArc( c ) );
Color outlineColor = getOutlineColor( c );
Color focusColor = null;
@@ -264,8 +268,8 @@ public class FlatBorder
* Returns the (unscaled) line thickness used to paint the border.
* This may be different to {@link #getLineWidth}.
*/
- protected int getBorderWidth( Component c ) {
- return getLineWidth( c );
+ protected float getBorderWidth( Component c ) {
+ return borderWidth;
}
/**
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonBorder.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonBorder.java
index 8917f559..19be5a93 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonBorder.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonBorder.java
@@ -32,53 +32,55 @@ import com.formdev.flatlaf.util.UIScale;
/**
* Border for {@link javax.swing.JButton}.
*
+ * @uiDefault Button.arc int
+ * @uiDefault Button.innerFocusWidth int or float optional; defaults to Component.innerFocusWidth
+ * @uiDefault Button.borderWidth int or float optional; defaults to Component.borderWidth
+ *
* @uiDefault Button.borderColor Color
* @uiDefault Button.startBorderColor Color optional; if set, a gradient paint is used and Button.borderColor is ignored
* @uiDefault Button.endBorderColor Color optional; if set, a gradient paint is used
* @uiDefault Button.disabledBorderColor Color
* @uiDefault Button.focusedBorderColor Color
* @uiDefault Button.hoverBorderColor Color optional
+ *
+ * @uiDefault Button.default.borderWidth int or float
* @uiDefault Button.default.borderColor Color
* @uiDefault Button.default.startBorderColor Color optional; if set, a gradient paint is used and Button.default.borderColor is ignored
* @uiDefault Button.default.endBorderColor Color optional; if set, a gradient paint is used
* @uiDefault Button.default.focusedBorderColor Color
* @uiDefault Button.default.focusColor Color
* @uiDefault Button.default.hoverBorderColor Color optional
+ *
+ * @uiDefault Button.toolbar.focusWidth int or float optional; default is 1.5
* @uiDefault Button.toolbar.focusColor Color optional; defaults to Component.focusColor
- * @uiDefault Button.borderWidth int
- * @uiDefault Button.default.borderWidth int
- * @uiDefault Button.innerFocusWidth int or float optional; defaults to Component.innerFocusWidth
* @uiDefault Button.toolbar.margin Insets
* @uiDefault Button.toolbar.spacingInsets Insets
- * @uiDefault Button.toolbar.focusWidth int or float optional; default is 1.5
- * @uiDefault Button.arc int
*
* @author Karl Tauber
*/
public class FlatButtonBorder
extends FlatBorder
{
+ @Styleable protected int arc = UIManager.getInt( "Button.arc" );
+
protected Color endBorderColor = UIManager.getColor( "Button.endBorderColor" );
@Styleable protected Color hoverBorderColor = UIManager.getColor( "Button.hoverBorderColor" );
+ @Styleable(dot=true) protected float defaultBorderWidth = FlatUIUtils.getUIFloat( "Button.default.borderWidth", 1 );
@Styleable(dot=true) protected Color defaultBorderColor = FlatUIUtils.getUIColor( "Button.default.startBorderColor", "Button.default.borderColor" );
protected Color defaultEndBorderColor = UIManager.getColor( "Button.default.endBorderColor" );
@Styleable(dot=true) protected Color defaultFocusedBorderColor = UIManager.getColor( "Button.default.focusedBorderColor" );
@Styleable(dot=true) protected Color defaultFocusColor = UIManager.getColor( "Button.default.focusColor" );
@Styleable(dot=true) protected Color defaultHoverBorderColor = UIManager.getColor( "Button.default.hoverBorderColor" );
- /** @since 1.4 */
- @Styleable(dot=true) protected Color toolbarFocusColor = UIManager.getColor( "Button.toolbar.focusColor" );
- @Styleable protected int borderWidth = UIManager.getInt( "Button.borderWidth" );
- @Styleable(dot=true) protected int defaultBorderWidth = UIManager.getInt( "Button.default.borderWidth" );
+ /** @since 1.4 */ @Styleable(dot=true) protected float toolbarFocusWidth = FlatUIUtils.getUIFloat( "Button.toolbar.focusWidth", 1.5f );
+ /** @since 1.4 */ @Styleable(dot=true) protected Color toolbarFocusColor = UIManager.getColor( "Button.toolbar.focusColor" );
@Styleable(dot=true) protected Insets toolbarMargin = UIManager.getInsets( "Button.toolbar.margin" );
@Styleable(dot=true) protected Insets toolbarSpacingInsets = UIManager.getInsets( "Button.toolbar.spacingInsets" );
- /** @since 1.4 */
- @Styleable(dot=true) protected float toolbarFocusWidth = FlatUIUtils.getUIFloat( "Button.toolbar.focusWidth", 1.5f );
- @Styleable protected int arc = UIManager.getInt( "Button.arc" );
public FlatButtonBorder() {
innerFocusWidth = FlatUIUtils.getUIFloat( "Button.innerFocusWidth", innerFocusWidth );
+ borderWidth = FlatUIUtils.getUIFloat( "Button.borderWidth", borderWidth );
borderColor = FlatUIUtils.getUIColor( "Button.startBorderColor", "Button.borderColor" );
disabledBorderColor = UIManager.getColor( "Button.disabledBorderColor" );
@@ -181,7 +183,7 @@ public class FlatButtonBorder
}
@Override
- protected int getBorderWidth( Component c ) {
+ protected float getBorderWidth( Component c ) {
return FlatButtonUI.isDefaultButton( c ) ? defaultBorderWidth : borderWidth;
}
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java
index 23474f05..fc083fc4 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java
@@ -101,6 +101,7 @@ import com.formdev.flatlaf.util.SystemInfo;
* @uiDefault ComboBox.buttonBackground Color
* @uiDefault ComboBox.buttonEditableBackground Color
* @uiDefault ComboBox.buttonFocusedBackground Color optional; defaults to ComboBox.focusedBackground
+ * @uiDefault ComboBox.buttonSeparatorWidth int or float optional; defaults to Component.borderWidth
* @uiDefault ComboBox.buttonSeparatorColor Color optional
* @uiDefault ComboBox.buttonDisabledSeparatorColor Color optional
* @uiDefault ComboBox.buttonArrowColor Color
@@ -129,6 +130,7 @@ public class FlatComboBoxUI
@Styleable protected Color buttonBackground;
@Styleable protected Color buttonEditableBackground;
@Styleable protected Color buttonFocusedBackground;
+ /** @since 2 */ @Styleable protected float buttonSeparatorWidth;
/** @since 2 */ @Styleable protected Color buttonSeparatorColor;
/** @since 2 */ @Styleable protected Color buttonDisabledSeparatorColor;
@Styleable protected Color buttonArrowColor;
@@ -223,6 +225,7 @@ public class FlatComboBoxUI
buttonBackground = UIManager.getColor( "ComboBox.buttonBackground" );
buttonFocusedBackground = UIManager.getColor( "ComboBox.buttonFocusedBackground" );
buttonEditableBackground = UIManager.getColor( "ComboBox.buttonEditableBackground" );
+ buttonSeparatorWidth = FlatUIUtils.getUIFloat( "ComboBox.buttonSeparatorWidth", FlatUIUtils.getUIFloat( "Component.borderWidth", 1 ) );
buttonSeparatorColor = UIManager.getColor( "ComboBox.buttonSeparatorColor" );
buttonDisabledSeparatorColor = UIManager.getColor( "ComboBox.buttonDisabledSeparatorColor" );
buttonArrowColor = UIManager.getColor( "ComboBox.buttonArrowColor" );
@@ -556,7 +559,7 @@ public class FlatComboBoxUI
Color separatorColor = enabled ? buttonSeparatorColor : buttonDisabledSeparatorColor;
if( separatorColor != null ) {
g2.setColor( separatorColor );
- float lw = scale( 1f );
+ float lw = scale( buttonSeparatorWidth );
float lx = isLeftToRight ? arrowX : arrowX + arrowWidth - lw;
g2.fill( new Rectangle2D.Float( lx, focusWidth, lw, height - 1 - (focusWidth * 2)) );
}
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSliderUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSliderUI.java
index 84f86b16..d87f20ca 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSliderUI.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSliderUI.java
@@ -65,6 +65,8 @@ import com.formdev.flatlaf.util.UIScale;
* @uiDefault Slider.trackWidth int
* @uiDefault Slider.thumbSize Dimension
* @uiDefault Slider.focusWidth int
+ * @uiDefault Slider.thumbBorderWidth int or float
+ *
* @uiDefault Slider.trackValueColor Color optional; defaults to Slider.thumbColor
* @uiDefault Slider.trackColor Color
* @uiDefault Slider.thumbColor Color
@@ -86,6 +88,7 @@ public class FlatSliderUI
@Styleable protected int trackWidth;
@Styleable protected Dimension thumbSize;
@Styleable protected int focusWidth;
+ /** @since 2 */ @Styleable protected float thumbBorderWidth;
@Styleable protected Color trackValueColor;
@Styleable protected Color trackColor;
@@ -139,6 +142,7 @@ public class FlatSliderUI
thumbSize = new Dimension( thumbWidth, thumbWidth );
}
focusWidth = FlatUIUtils.getUIInt( "Slider.focusWidth", 4 );
+ thumbBorderWidth = FlatUIUtils.getUIFloat( "Slider.thumbBorderWidth", 1 );
trackValueColor = FlatUIUtils.getUIColor( "Slider.trackValueColor", "Slider.thumbColor" );
trackColor = UIManager.getColor( "Slider.trackColor" );
@@ -405,11 +409,11 @@ debug*/
Color focusedColor = FlatUIUtils.deriveColor( this.focusedColor,
(foreground != defaultForeground) ? foreground : focusBaseColor );
- paintThumb( g, slider, thumbRect, isRoundThumb(), color, borderColor, focusedColor, focusWidth );
+ paintThumb( g, slider, thumbRect, isRoundThumb(), color, borderColor, focusedColor, thumbBorderWidth, focusWidth );
}
public static void paintThumb( Graphics g, JSlider slider, Rectangle thumbRect, boolean roundThumb,
- Color thumbColor, Color thumbBorderColor, Color focusedColor, int focusWidth )
+ Color thumbColor, Color thumbBorderColor, Color focusedColor, float thumbBorderWidth, int focusWidth )
{
double systemScaleFactor = UIScale.getSystemScaleFactor( (Graphics2D) g );
if( systemScaleFactor != 1 && systemScaleFactor != 2 ) {
@@ -418,18 +422,20 @@ debug*/
(g2d, x2, y2, width2, height2, scaleFactor) -> {
paintThumbImpl( g, slider, x2, y2, width2, height2,
roundThumb, thumbColor, thumbBorderColor, focusedColor,
+ (float) (thumbBorderWidth * scaleFactor),
(float) (focusWidth * scaleFactor) );
} );
return;
}
paintThumbImpl( g, slider, thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height,
- roundThumb, thumbColor, thumbBorderColor, focusedColor, focusWidth );
+ roundThumb, thumbColor, thumbBorderColor, focusedColor, thumbBorderWidth, focusWidth );
}
private static void paintThumbImpl( Graphics g, JSlider slider, int x, int y, int width, int height,
- boolean roundThumb, Color thumbColor, Color thumbBorderColor, Color focusedColor, float focusWidth )
+ boolean roundThumb, Color thumbColor, Color thumbBorderColor, Color focusedColor,
+ float thumbBorderWidth, float focusWidth )
{
int fw = Math.round( UIScale.scale( focusWidth ) );
int tx = x + fw;
@@ -451,7 +457,7 @@ debug*/
((Graphics2D)g).fill( createRoundThumbShape( tx, ty, tw, th ) );
// paint thumb background
- float lw = UIScale.scale( 1f );
+ float lw = UIScale.scale( thumbBorderWidth );
g.setColor( thumbColor );
((Graphics2D)g).fill( createRoundThumbShape( tx + lw, ty + lw,
tw - lw - lw, th - lw - lw ) );
@@ -492,7 +498,7 @@ debug*/
g2.fill( createDirectionalThumbShape( fw, fw, tw, th, 0 ) );
// paint thumb background
- float lw = UIScale.scale( 1f );
+ float lw = UIScale.scale( thumbBorderWidth );
g2.setColor( thumbColor );
g2.fill( createDirectionalThumbShape( fw + lw, fw + lw,
tw - lw - lw, th - lw - lw - (lw * 0.4142f), 0 ) );
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSpinnerUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSpinnerUI.java
index 79935f33..61afc4e0 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSpinnerUI.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSpinnerUI.java
@@ -72,6 +72,7 @@ import com.formdev.flatlaf.util.LoggingFacade;
* @uiDefault Spinner.disabledForeground Color
* @uiDefault Spinner.focusedBackground Color optional
* @uiDefault Spinner.buttonBackground Color
+ * @uiDefault Spinner.buttonSeparatorWidth int or float optional; defaults to Component.borderWidth
* @uiDefault Spinner.buttonSeparatorColor Color optional
* @uiDefault Spinner.buttonDisabledSeparatorColor Color optional
* @uiDefault Spinner.buttonArrowColor Color
@@ -96,6 +97,7 @@ public class FlatSpinnerUI
@Styleable protected Color disabledForeground;
@Styleable protected Color focusedBackground;
@Styleable protected Color buttonBackground;
+ /** @since 2 */ @Styleable protected float buttonSeparatorWidth;
/** @since 2 */ @Styleable protected Color buttonSeparatorColor;
/** @since 2 */ @Styleable protected Color buttonDisabledSeparatorColor;
@Styleable protected Color buttonArrowColor;
@@ -132,6 +134,7 @@ public class FlatSpinnerUI
disabledForeground = UIManager.getColor( "Spinner.disabledForeground" );
focusedBackground = UIManager.getColor( "Spinner.focusedBackground" );
buttonBackground = UIManager.getColor( "Spinner.buttonBackground" );
+ buttonSeparatorWidth = FlatUIUtils.getUIFloat( "Spinner.buttonSeparatorWidth", FlatUIUtils.getUIFloat( "Component.borderWidth", 1 ) );
buttonSeparatorColor = UIManager.getColor( "Spinner.buttonSeparatorColor" );
buttonDisabledSeparatorColor = UIManager.getColor( "Spinner.buttonDisabledSeparatorColor" );
buttonArrowColor = UIManager.getColor( "Spinner.buttonArrowColor" );
@@ -397,7 +400,7 @@ public class FlatSpinnerUI
Color separatorColor = enabled ? buttonSeparatorColor : buttonDisabledSeparatorColor;
if( separatorColor != null ) {
g2.setColor( separatorColor );
- float lw = scale( 1f );
+ float lw = scale( buttonSeparatorWidth );
float lx = isLeftToRight ? arrowX : arrowX + arrowWidth - lw;
g2.fill( new Rectangle2D.Float( lx, focusWidth, lw, height - 1 - (focusWidth * 2) ) );
}
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java
index 990a995f..3adc07a7 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java
@@ -409,7 +409,7 @@ public class FlatUIUtils
* Border:
* The outside bounds of the painted border are
* {@code [x + focusWidth, y + focusWidth, width - (focusWidth * 2), height - (focusWidth * 2)]}.
- * The thickness of the painted border is {@code lineWidth}.
+ * The thickness of the painted border is {@code borderWidth}.
*
* @param g the graphics context used for painting
* @param x the x coordinate of the component
@@ -422,7 +422,7 @@ public class FlatUIUtils
* the painted thickness of the focus border is {@code (focusWidth * focusWidthFraction) + focusInnerWidth}
* @param focusInnerWidth the inner width of the focus border, or {@code 0};
* if a border is painted then {@code focusInnerWidth} needs to be larger
- * than {@code lineWidth} to be not hidden by the border
+ * than {@code borderWidth} to be not hidden by the border
* @param borderWidth the width of the border, or {@code 0}
* @param arc the arc diameter used for the outside shape of the component border;
* the other needed arc diameters are computed from this arc diameter
diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties
index 3f457347..641d93f3 100644
--- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties
+++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties
@@ -228,6 +228,7 @@ ComboBox.buttonPressedArrowColor = @buttonPressedArrowColor
Component.focusWidth = 0
Component.innerFocusWidth = 0.5
Component.innerOutlineWidth = 1
+Component.borderWidth = 1
Component.arc = 5
Component.minimumWidth = 64
# allowed values: chevron or triangle
diff --git a/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyleableInfo.java b/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyleableInfo.java
index 56f3a74c..868d7ddb 100644
--- a/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyleableInfo.java
+++ b/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyleableInfo.java
@@ -164,6 +164,7 @@ public class TestFlatStyleableInfo
"buttonBackground", Color.class,
"buttonFocusedBackground", Color.class,
"buttonEditableBackground", Color.class,
+ "buttonSeparatorWidth", float.class,
"buttonSeparatorColor", Color.class,
"buttonDisabledSeparatorColor", Color.class,
"buttonArrowColor", Color.class,
@@ -456,7 +457,7 @@ public class TestFlatStyleableInfo
radioButton( expected );
expectedMap( expected,
- "icon.centerDiameter", int.class
+ "icon.centerDiameter", float.class
);
assertMapEquals( expected, ui.getStyleableInfos( c ) );
@@ -470,6 +471,7 @@ public class TestFlatStyleableInfo
"icon.focusWidth", int.class,
"icon.focusColor", Color.class,
+ "icon.borderWidth", float.class,
"icon.arc", int.class,
// enabled
@@ -580,6 +582,7 @@ public class TestFlatStyleableInfo
"trackWidth", int.class,
"thumbSize", Dimension.class,
"focusWidth", int.class,
+ "thumbBorderWidth", float.class,
"trackValueColor", Color.class,
"trackColor", Color.class,
@@ -611,6 +614,7 @@ public class TestFlatStyleableInfo
"disabledForeground", Color.class,
"focusedBackground", Color.class,
"buttonBackground", Color.class,
+ "buttonSeparatorWidth", float.class,
"buttonSeparatorColor", Color.class,
"buttonDisabledSeparatorColor", Color.class,
"buttonArrowColor", Color.class,
@@ -901,23 +905,23 @@ public class TestFlatStyleableInfo
flatBorder( expected );
expectedMap( expected,
+ "arc", int.class,
+
"borderColor", Color.class,
"disabledBorderColor", Color.class,
"focusedBorderColor", Color.class,
"hoverBorderColor", Color.class,
+ "default.borderWidth", float.class,
"default.borderColor", Color.class,
"default.focusedBorderColor", Color.class,
"default.focusColor", Color.class,
"default.hoverBorderColor", Color.class,
- "toolbar.focusColor", Color.class,
- "borderWidth", int.class,
- "default.borderWidth", int.class,
- "toolbar.margin", Insets.class,
- "toolbar.spacingInsets", Insets.class,
"toolbar.focusWidth", float.class,
- "arc", int.class
+ "toolbar.focusColor", Color.class,
+ "toolbar.margin", Insets.class,
+ "toolbar.spacingInsets", Insets.class
);
}
@@ -946,6 +950,8 @@ public class TestFlatStyleableInfo
"focusWidth", int.class,
"innerFocusWidth", float.class,
"innerOutlineWidth", float.class,
+ "borderWidth", float.class,
+
"focusColor", Color.class,
"borderColor", Color.class,
"disabledBorderColor", Color.class,
@@ -1026,7 +1032,7 @@ public class TestFlatStyleableInfo
flatCheckBoxIcon( expected );
expectedMap( expected,
- "centerDiameter", int.class
+ "centerDiameter", float.class
);
assertMapEquals( expected, icon.getStyleableInfos() );
@@ -1036,6 +1042,7 @@ public class TestFlatStyleableInfo
expectedMap( expected,
"focusWidth", int.class,
"focusColor", Color.class,
+ "borderWidth", float.class,
"arc", int.class,
// enabled
diff --git a/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java b/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java
index d8147afd..f8b585bf 100644
--- a/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java
+++ b/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java
@@ -294,6 +294,7 @@ public class TestFlatStyling
ui.applyStyle( "buttonBackground: #fff" );
ui.applyStyle( "buttonFocusedBackground: #fff" );
ui.applyStyle( "buttonEditableBackground: #fff" );
+ ui.applyStyle( "buttonSeparatorWidth: 1.5" );
ui.applyStyle( "buttonSeparatorColor: #fff" );
ui.applyStyle( "buttonDisabledSeparatorColor: #fff" );
ui.applyStyle( "buttonArrowColor: #fff" );
@@ -609,6 +610,7 @@ public class TestFlatStyling
ui.applyStyle( b, "icon.focusWidth: 2" );
ui.applyStyle( b, "icon.focusColor: #fff" );
+ ui.applyStyle( b, "icon.borderWidth: 1" );
ui.applyStyle( b, "icon.arc: 5" );
// enabled
@@ -719,6 +721,7 @@ public class TestFlatStyling
ui.applyStyle( "trackWidth: 2" );
ui.applyStyle( "thumbSize: 12,12" );
ui.applyStyle( "focusWidth: 4" );
+ ui.applyStyle( "thumbBorderWidth: 1.5" );
ui.applyStyle( "trackValueColor: #fff" );
ui.applyStyle( "trackColor: #fff" );
@@ -769,6 +772,7 @@ public class TestFlatStyling
ui.applyStyle( "disabledForeground: #fff" );
ui.applyStyle( "focusedBackground: #fff" );
ui.applyStyle( "buttonBackground: #fff" );
+ ui.applyStyle( "buttonSeparatorWidth: 1.5" );
ui.applyStyle( "buttonSeparatorColor: #fff" );
ui.applyStyle( "buttonDisabledSeparatorColor: #fff" );
ui.applyStyle( "buttonArrowColor: #fff" );
@@ -1109,23 +1113,23 @@ public class TestFlatStyling
private void flatButtonBorder( Consumer