From a909f1012a3164ceed96ed774af3e4bd789181d0 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Fri, 16 Oct 2020 12:25:04 +0200 Subject: [PATCH] TabbedPane: finally get rid of the cropped edge (issue #40) --- .../com/formdev/flatlaf/ui/FlatTabbedPaneUI.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 80cbed5d..5861481a 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 @@ -435,6 +435,21 @@ public class FlatTabbedPaneUI return Math.max( tabHeight, super.calculateTabHeight( tabPlacement, tabIndex, fontHeight ) - 2 /* was added by superclass */ ); } + @Override + protected Insets getTabAreaInsets( int tabPlacement ) { + Insets currentTabAreaInsets = super.getTabAreaInsets( tabPlacement ); + Insets insets = (Insets) currentTabAreaInsets.clone(); + + // This is a "trick" to get rid of the cropped edge: + // super.getTabAreaInsets() returns private field BasicTabbedPaneUI.currentTabAreaInsets, + // which is also used to translate the origin of the cropped edge in + // BasicTabbedPaneUI.CroppedEdge.paintComponent(). + // Giving it large values clips painting of the cropped edge and makes it invisible. + currentTabAreaInsets.top = currentTabAreaInsets.left = -10000; + + return insets; + } + /** * The content border insets are used to create a separator between tabs and content. * If client property JTabbedPane.hasFullBorder is true, then the content border insets