Button: changed styling of default button in "Flat Light" theme (wide blue border instead of blue background)

This commit is contained in:
Karl Tauber
2019-10-05 14:58:49 +02:00
parent 2da0ca736f
commit 8806cc8e93
7 changed files with 38 additions and 11 deletions

View File

@@ -12,6 +12,8 @@ FlatLaf Change Log
- If a JButton has an icon and no text, then it does not get a minimum width
(usually 72 pixel) and the left and right insets are same as top/bottom insets
so that it becomes square (if the icon is square).
- Changed styling of default button in "Flat Light" theme (wide blue border
instead of blue background).
- Added Java 9 module descriptor `module-info.class` to `flatlaf.jar` (in
`META-INF/versions/9`). But FlatLaf remains Java 8 compatible. (issue #1)
- Support specifying custom scale factor in system properties `flatlaf.uiScale`

View File

@@ -73,17 +73,17 @@ public class FlatBorder
FlatUIUtils.setRenderingHints( g2 );
float focusWidth = getFocusWidth();
float lineWidth = getLineWidth();
float borderWidth = getBorderWidth( c );
float arc = getArc();
if( isFocused( c ) ) {
g2.setColor( getFocusColor( c ) );
FlatUIUtils.paintOutlineBorder( g2, x, y, width, height, focusWidth,
lineWidth + scale( (float) innerFocusWidth ), arc );
getLineWidth() + scale( (float) innerFocusWidth ), arc );
}
g2.setPaint( getBorderColor( c ) );
FlatUIUtils.drawRoundRectangle( g2, x, y, width, height, focusWidth, lineWidth, arc );
FlatUIUtils.drawRoundRectangle( g2, x, y, width, height, focusWidth, borderWidth, arc );
} finally {
g2.dispose();
}
@@ -152,6 +152,10 @@ public class FlatBorder
return scale( 1f );
}
protected float getBorderWidth( Component c ) {
return getLineWidth();
}
protected float getArc() {
return 0;
}

View File

@@ -37,6 +37,7 @@ import javax.swing.plaf.UIResource;
* @uiDefault Button.default.hoverBorderColor Color optional
* @uiDefault Button.default.focusedBorderColor Color
* @uiDefault Button.default.focusColor Color
* @uiDefault Button.default.borderWidth int
* @uiDefault Button.arc int
*
* @author Karl Tauber
@@ -52,6 +53,7 @@ public class FlatButtonBorder
protected final Color defaultHoverBorderColor = UIManager.getColor( "Button.default.hoverBorderColor" );
protected final Color defaultFocusedBorderColor = UIManager.getColor( "Button.default.focusedBorderColor" );
protected final Color defaultFocusColor = UIManager.getColor( "Button.default.focusColor" );
protected final int defaultBorderWidth = UIManager.getInt( "Button.default.borderWidth" );
protected final int arc = UIManager.getInt( "Button.arc" );
@Override
@@ -87,6 +89,11 @@ public class FlatButtonBorder
return insets;
}
@Override
protected float getBorderWidth( Component c ) {
return FlatButtonUI.isDefaultButton( c ) ? scale( (float) defaultBorderWidth ) : super.getBorderWidth( c );
}
@Override
protected float getArc() {
return scale( (float) arc );

View File

@@ -79,6 +79,7 @@ Button.default.borderColor=4c708c
Button.default.hoverBorderColor=537699
Button.default.focusedBorderColor=537699
Button.default.focusColor=43688c
Button.default.boldText=true
Button.toolbar.hoverBackground=4c5052
Button.toolbar.pressedBackground=555a5d

View File

@@ -22,6 +22,15 @@
Button.focusedBackground=null
Button.default.background=4A86C7
Button.default.foreground=f0f0f0
Button.default.focusedBackground=null
Button.default.hoverBackground=5B91CC
Button.default.pressedBackground=6E9ED2
Button.default.borderColor=3167ad
Button.default.hoverBorderColor=a8cef6
Button.default.focusedBorderColor=a8cef6
Button.default.focusColor=97c3f3
Button.default.boldText=true

View File

@@ -70,6 +70,8 @@ Button.iconTextGap=4
Button.rollover=true
Button.defaultButtonFollowsFocus=false
Button.default.borderWidth=1
#---- CheckBox ----

View File

@@ -72,14 +72,16 @@ Button.disabledBorderColor=cfcfcf
Button.focusedBorderColor=87afda
Button.hoverBorderColor=@@Button.focusedBorderColor
Button.default.background=4A86C7
Button.default.foreground=f0f0f0
Button.default.hoverBackground=5B91CC
Button.default.pressedBackground=6E9ED2
Button.default.borderColor=3167ad
Button.default.hoverBorderColor=a8cef6
Button.default.focusedBorderColor=a8cef6
Button.default.focusColor=97c3f3
Button.default.background=@@Button.background
Button.default.foreground=@foreground
Button.default.focusedBackground=@@Button.focusedBackground
Button.default.hoverBackground=@@Button.hoverBackground
Button.default.pressedBackground=@@Button.pressedBackground
Button.default.borderColor=4D89C9
Button.default.hoverBorderColor=@@Button.hoverBorderColor
Button.default.focusedBorderColor=@@Button.focusedBorderColor
Button.default.focusColor=@@Component.focusColor
Button.default.borderWidth=2
Button.toolbar.hoverBackground=dfdfdf
Button.toolbar.pressedBackground=d8d8d8