Skip to content

Commit

Permalink
Button: changed styling of default button in "Flat Light" theme (wide…
Browse files Browse the repository at this point in the history
… blue border instead of blue background)
  • Loading branch information
DevCharly committed Oct 5, 2019
1 parent 2da0ca7 commit 8806cc8
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ public void paintBorder( Component c, Graphics g, int x, int y, int width, int h
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();
}
Expand Down Expand Up @@ -152,6 +152,10 @@ protected float getLineWidth() {
return scale( 1f );
}

protected float getBorderWidth( Component c ) {
return getLineWidth();
}

protected float getArc() {
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* @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
Expand All @@ -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
Expand Down Expand Up @@ -87,6 +89,11 @@ public Insets getBorderInsets( Component c, Insets insets ) {
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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ Button.iconTextGap=4
Button.rollover=true
Button.defaultButtonFollowsFocus=false

Button.default.borderWidth=1


#---- CheckBox ----

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8806cc8

Please sign in to comment.