diff --git a/CHANGELOG.md b/CHANGELOG.md index 373edb1c..a9aa76a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ FlatLaf Change Log - TabbedPane: Support background color for selected tabs. - CheckBox: changed `CheckBox.arc` from radius to diameter to be consistent with `Button.arc` and `Component.arc` +- Button: Enabled `Button.defaultButtonFollowsFocus` on Windows, which allows + pressing focused button with Enter key (as in Windows LaF). - Fixed clipped borders at 125%, 150% and 175% scaling when outer focus width is zero (default in "Flat Light" and "Flat Dark" themes). 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 33fcc443..3a7a00d4 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -94,6 +94,7 @@ Button.margin=2,14,2,14 Button.iconTextGap=4 Button.rollover=true Button.defaultButtonFollowsFocus=false +[win]Button.defaultButtonFollowsFocus=true Button.default.borderWidth=1 diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/ControlBar.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/ControlBar.java index 222c4c41..f899266e 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/ControlBar.java +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/ControlBar.java @@ -77,6 +77,9 @@ class ControlBar EventQueue.invokeLater( () -> { // update info label because user scale factor may change updateInfoLabel(); + + // this is necessary because embedded JOptionPane's "steal" the default button + frame.getRootPane().setDefaultButton( closeButton ); } ); } } ); diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java index 62a47a54..36ac6541 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java @@ -143,6 +143,9 @@ public class FlatTestFrame KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0, false ), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ); + // make the "close" button the default button + getRootPane().setDefaultButton( closeButton ); + // close frame closeButton.addActionListener(e -> dispose()); @@ -170,6 +173,9 @@ public class FlatTestFrame // enable/disable scale factor combobox updateScaleFactorComboBox(); + + // this is necessary because embedded JOptionPane's "steal" the default button + getRootPane().setDefaultButton( closeButton ); } ); } } );