Skip to content

Commit

Permalink
Button and ToggleButton:
Browse files Browse the repository at this point in the history
- updated CHANGELOG.md for #276
- FlatComponentsTest: use FlatButton and FlatToggleButton
- FlatButtonUI: avoid unnecessary reading client property if shadowColor is null, which is the case in most themes
  • Loading branch information
DevCharly committed Apr 9, 2021
1 parent c55f0e2 commit 5eab843
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
FlatLaf Change Log
==================

## 1.2-SNAPSHOT

#### New features and improvements

- Button and ToggleButton: Support borderless button style (set client property
`JButton.buttonType` to `borderless`). (PR #276)


## 1.1.2

#### New features and improvements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,9 @@ protected void paintBackground( Graphics g, JComponent c ) {

// paint shadow
Color shadowColor = def ? defaultShadowColor : this.shadowColor;
if( !isToolBarButton && !isBorderlessButton( c ) && shadowColor != null && shadowWidth > 0 && focusWidth > 0 &&
!(isFocusPainted( c ) && FlatUIUtils.isPermanentFocusOwner( c )) && c.isEnabled() )
if( shadowColor != null && shadowWidth > 0 && focusWidth > 0 && c.isEnabled() &&
!isToolBarButton && !isBorderlessButton( c ) &&
!(isFocusPainted( c ) && FlatUIUtils.isPermanentFocusOwner( c )) )
{
g2.setColor( shadowColor );
g2.fill( new RoundRectangle2D.Float( focusWidth, focusWidth + UIScale.scale( (float) shadowWidth ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private void initComponents() {
JButton button16 = new JButton();
JButton button24 = new JButton();
JButton button20 = new JButton();
JButton button25 = new JButton();
FlatButton button25 = new FlatButton();
JLabel toggleButtonLabel = new JLabel();
JToggleButton toggleButton1 = new JToggleButton();
FlatToggleButton toggleButton9 = new FlatToggleButton();
Expand All @@ -269,7 +269,7 @@ private void initComponents() {
JToggleButton toggleButton14 = new JToggleButton();
JToggleButton toggleButton21 = new JToggleButton();
JToggleButton toggleButton18 = new JToggleButton();
JToggleButton toggleButton22 = new JToggleButton();
FlatToggleButton toggleButton22 = new FlatToggleButton();
JLabel checkBoxLabel = new JLabel();
JCheckBox checkBox1 = new JCheckBox();
JCheckBox checkBox2 = new JCheckBox();
Expand Down Expand Up @@ -582,7 +582,7 @@ private void initComponents() {

//---- button25 ----
button25.setIcon(UIManager.getIcon("Tree.closedIcon"));
button25.putClientProperty("JButton.buttonType", "borderLess");
button25.setButtonType(FlatButton.ButtonType.borderless);
add(button25, "cell 5 1 2 1");

//---- toggleButtonLabel ----
Expand Down Expand Up @@ -665,7 +665,7 @@ private void initComponents() {
//---- toggleButton22 ----
toggleButton22.setIcon(UIManager.getIcon("Tree.closedIcon"));
toggleButton22.setSelected(true);
toggleButton22.putClientProperty("JButton.buttonType", "borderLess");
toggleButton22.setButtonType(FlatButton.ButtonType.borderless);
add(toggleButton22, "cell 5 2 2 1");

//---- checkBoxLabel ----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 1 2 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
name: "button25"
"icon": &SwingIcon0 new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
"$client.JButton.buttonType": "borderLess"
"buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType borderless
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 1 2 1"
} )
Expand Down Expand Up @@ -270,11 +270,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 2 2 1"
} )
add( new FormComponent( "javax.swing.JToggleButton" ) {
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatToggleButton" ) {
name: "toggleButton22"
"icon": &SwingIcon0 new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
"selected": true
"$client.JButton.buttonType": "borderLess"
"buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType borderless
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 2 2 1"
} )
Expand Down

0 comments on commit 5eab843

Please sign in to comment.