updates for PR #530:

- added @since tags
- changed `FlatToggleButton.setTabUnderlinePlacement()` implementation so that is behaves similar to `FlatTabbedPane.setTabIconPlacement()`
This commit is contained in:
Karl Tauber
2022-05-09 22:28:34 +02:00
parent 38cf32a2e9
commit 02cf6050a1
3 changed files with 14 additions and 15 deletions

View File

@@ -5,6 +5,8 @@ FlatLaf Change Log
#### New features and improvements #### New features and improvements
- ToggleButton: Made the underline placement of tab-style toggle buttons
configurable. (PR #530; issue #529)
- Added spanish translation. (PR #525) - Added spanish translation. (PR #525)
#### Fixed bugs #### Fixed bugs

View File

@@ -996,19 +996,13 @@ public interface FlatClientProperties
* <p> * <p>
* <strong>Component</strong> {@link javax.swing.JToggleButton}<br> * <strong>Component</strong> {@link javax.swing.JToggleButton}<br>
* <strong>Value type</strong> {@link java.lang.Integer}<br> * <strong>Value type</strong> {@link java.lang.Integer}<br>
* <strong>Default value</strong> {@link SwingConstants#BOTTOM}<br>
* <strong>SupportedValues:</strong> * <strong>SupportedValues:</strong>
* <table> * {@link SwingConstants#BOTTOM} (default)
* <thead> * {@link SwingConstants#TOP},
* <tr><td>Placement</td><td>Constant</td><td>Value</td></tr> * {@link SwingConstants#LEFT} or
* </thead> * {@link SwingConstants#RIGHT}
* <tbody> *
* <tr><td>TOP</td><td>{@link SwingConstants#TOP}</td><td>{@value SwingConstants#TOP}</td></tr> * @since 2.3
* <tr><td>LEFT</td><td>{@link SwingConstants#LEFT}</td><td>{@value SwingConstants#LEFT}</td></tr>
* <tr><td>BOTTOM</td><td>{@link SwingConstants#BOTTOM}</td><td>{@value SwingConstants#BOTTOM}</td></tr>
* <tr><td>RIGHT</td><td>{@link SwingConstants#RIGHT}</td><td>{@value SwingConstants#RIGHT}</td></tr>
* </tbody>
* </table>
*/ */
String TAB_BUTTON_UNDERLINE_PLACEMENT = "JToggleButton.tab.underlinePlacement"; String TAB_BUTTON_UNDERLINE_PLACEMENT = "JToggleButton.tab.underlinePlacement";

View File

@@ -120,6 +120,8 @@ public class FlatToggleButton
* Returns placement of underline if toggle button type is {@link ButtonType#tab}. * Returns placement of underline if toggle button type is {@link ButtonType#tab}.
* If underline placement is not specified, returns {@link #BOTTOM} as the default * If underline placement is not specified, returns {@link #BOTTOM} as the default
* value. * value.
*
* @since 2.3
*/ */
public int getTabUnderlinePlacement() { public int getTabUnderlinePlacement() {
return getClientPropertyInt( TAB_BUTTON_UNDERLINE_PLACEMENT, BOTTOM ); return getClientPropertyInt( TAB_BUTTON_UNDERLINE_PLACEMENT, BOTTOM );
@@ -130,20 +132,21 @@ public class FlatToggleButton
* *
* @param placement One of the following constants defined in SwingConstants: * @param placement One of the following constants defined in SwingConstants:
* {@link #TOP}, {@link #LEFT}, {@link #BOTTOM}, or {@link #RIGHT}. * {@link #TOP}, {@link #LEFT}, {@link #BOTTOM}, or {@link #RIGHT}.
* @since 2.3
*/ */
public void setTabUnderlinePlacement( int placement ) { 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() { public int getTabUnderlineHeight() {
return getClientPropertyInt( TAB_BUTTON_UNDERLINE_HEIGHT, "ToggleButton.tab.underlineHeight" ); 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 ) { public void setTabUnderlineHeight( int tabUnderlineHeight ) {
putClientProperty( TAB_BUTTON_UNDERLINE_HEIGHT, (tabUnderlineHeight >= 0) ? tabUnderlineHeight : null ); putClientProperty( TAB_BUTTON_UNDERLINE_HEIGHT, (tabUnderlineHeight >= 0) ? tabUnderlineHeight : null );