diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b5064610..814e9d985 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java index 8d730b466..45b6f4022 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java @@ -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 ), diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java index d52f266af..b74c3aa85 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java @@ -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(); @@ -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(); @@ -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 ---- @@ -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 ---- diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd index 9d8c6cfc4..a219f63bb 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd @@ -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" } ) @@ -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" } )