From 04bb6a5275f82b3aeae4d6b761ebc99903340312 Mon Sep 17 00:00:00 2001 From: DUDSS Date: Sun, 20 Jun 2021 02:10:51 +0200 Subject: [PATCH] TabbedPane: Adjustements --- .../formdev/flatlaf/ui/FlatTabbedPaneUI.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTabbedPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTabbedPaneUI.java index c3a99e9f..37010b1e 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTabbedPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTabbedPaneUI.java @@ -98,6 +98,7 @@ import com.formdev.flatlaf.util.UIScale; * * @clientProperty JTabbedPane.showTabSeparators boolean * @clientProperty JTabbedPane.hasFullBorder boolean + * @clientProperty JTabbedPane.activeTabBorder boolean * * * @@ -135,6 +136,7 @@ import com.formdev.flatlaf.util.UIScale; * @uiDefault TabbedPane.showTabSeparators boolean * @uiDefault TabbedPane.tabSeparatorsFullHeight boolean * @uiDefault TabbedPane.hasFullBorder boolean + * @uiDefault TabbedPane.activeTabBorder boolean * * @uiDefault TabbedPane.tabLayoutPolicy String wrap (default) or scroll * @uiDefault TabbedPane.tabsPopupPolicy String never or asNeeded (default) @@ -1014,10 +1016,19 @@ public class FlatTabbedPaneUI { // paint tab separators if( clientPropertyBoolean( tabPane, TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators ) && - !isLastInRun( tabIndex ) ) - paintTabSeparator( g, tabPlacement, x, y, w, h ); + !isLastInRun( tabIndex ) ) { + if( clientPropertyBoolean( tabPane, TABBED_PANE_ACTIVE_TAB_BORDER, activeTabBorder ) ) { + // Some separators need to be omitted when activeTabBorder is enabled + int selectedIndex = tabPane.getSelectedIndex(); + if (tabIndex != selectedIndex - 1 && tabIndex != selectedIndex) { + paintTabSeparator( g, tabPlacement, x, y, w, h ); + } + } else { + paintTabSeparator( g, tabPlacement, x, y, w, h ); + } + } - // paint tab border + // paint active tab border if ( clientPropertyBoolean( tabPane, TABBED_PANE_ACTIVE_TAB_BORDER, activeTabBorder ) && isSelected) { paintActiveTabBorder(g, tabPlacement, tabIndex, x, y, w, h); } @@ -1101,7 +1112,7 @@ public class FlatTabbedPaneUI case BOTTOM: if ( clientPropertyBoolean( tabPane, TABBED_PANE_ACTIVE_TAB_BORDER, activeTabBorder )) { - g.fillRect( x, y + h + contentInsets.top - tabSelectionHeight, w, tabSelectionHeight ); + g.fillRect( x, y + h - tabSelectionHeight, w, tabSelectionHeight ); } else { g.fillRect( x, y - contentInsets.bottom, w, tabSelectionHeight ); } @@ -1119,7 +1130,7 @@ public class FlatTabbedPaneUI case RIGHT: if ( clientPropertyBoolean( tabPane, TABBED_PANE_ACTIVE_TAB_BORDER, activeTabBorder )) { - g.fillRect( x + w + contentInsets.left - tabSelectionHeight, y, tabSelectionHeight, h ); + g.fillRect( x + w - tabSelectionHeight, y, tabSelectionHeight, h ); } else { g.fillRect( x - contentInsets.right, y, tabSelectionHeight, h ); }