From 02cf6050a1e7f1d61a910107324fec1ff520da6c Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Mon, 9 May 2022 22:28:34 +0200 Subject: [PATCH] updates for PR #530: - added @since tags - changed `FlatToggleButton.setTabUnderlinePlacement()` implementation so that is behaves similar to `FlatTabbedPane.setTabIconPlacement()` --- CHANGELOG.md | 2 ++ .../formdev/flatlaf/FlatClientProperties.java | 18 ++++++------------ .../extras/components/FlatToggleButton.java | 9 ++++++--- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index efc57e92..dda9b960 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ FlatLaf Change Log #### New features and improvements +- ToggleButton: Made the underline placement of tab-style toggle buttons + configurable. (PR #530; issue #529) - Added spanish translation. (PR #525) #### Fixed bugs diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java index 38e3560c..18c64934 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java @@ -996,19 +996,13 @@ public interface FlatClientProperties *

* Component {@link javax.swing.JToggleButton}
* Value type {@link java.lang.Integer}
- * Default value {@link SwingConstants#BOTTOM}
* SupportedValues: - * - * - * - * - * - * - * - * - * - * - *
PlacementConstantValue
TOP{@link SwingConstants#TOP}{@value SwingConstants#TOP}
LEFT{@link SwingConstants#LEFT}{@value SwingConstants#LEFT}
BOTTOM{@link SwingConstants#BOTTOM}{@value SwingConstants#BOTTOM}
RIGHT{@link SwingConstants#RIGHT}{@value SwingConstants#RIGHT}
+ * {@link SwingConstants#BOTTOM} (default) + * {@link SwingConstants#TOP}, + * {@link SwingConstants#LEFT} or + * {@link SwingConstants#RIGHT} + * + * @since 2.3 */ String TAB_BUTTON_UNDERLINE_PLACEMENT = "JToggleButton.tab.underlinePlacement"; diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatToggleButton.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatToggleButton.java index 3190223b..b8eca017 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatToggleButton.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatToggleButton.java @@ -120,6 +120,8 @@ public class FlatToggleButton * Returns placement of underline if toggle button type is {@link ButtonType#tab}. * If underline placement is not specified, returns {@link #BOTTOM} as the default * value. + * + * @since 2.3 */ public int getTabUnderlinePlacement() { return getClientPropertyInt( TAB_BUTTON_UNDERLINE_PLACEMENT, BOTTOM ); @@ -130,20 +132,21 @@ public class FlatToggleButton * * @param placement One of the following constants defined in SwingConstants: * {@link #TOP}, {@link #LEFT}, {@link #BOTTOM}, or {@link #RIGHT}. + * @since 2.3 */ public void setTabUnderlinePlacement( int placement ) { - putClientProperty( TAB_BUTTON_UNDERLINE_PLACEMENT, (placement < 0 || placement >= RIGHT) ? null : placement); + putClientProperty( TAB_BUTTON_UNDERLINE_PLACEMENT, (placement >= 0) ? placement : null ); } /** - * Returns height of underline if toggle button type is {@link ButtonType#tab}. + * Returns thickness of underline if toggle button type is {@link ButtonType#tab}. */ public int getTabUnderlineHeight() { return getClientPropertyInt( TAB_BUTTON_UNDERLINE_HEIGHT, "ToggleButton.tab.underlineHeight" ); } /** - * Specifies height of underline if toggle button type is {@link ButtonType#tab}. + * Specifies thickness of underline if toggle button type is {@link ButtonType#tab}. */ public void setTabUnderlineHeight( int tabUnderlineHeight ) { putClientProperty( TAB_BUTTON_UNDERLINE_HEIGHT, (tabUnderlineHeight >= 0) ? tabUnderlineHeight : null );