From 53fce4e81d32a08479cd1991f1f67ebb1d78c2c9 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sat, 23 May 2020 14:16:12 +0200 Subject: [PATCH] ScrollBar: rotate track/thumb insets for horizontal orientation because they are given for vertical orientation (issue #103) --- .../main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java index a0ff0403..32a4ce25 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java @@ -30,6 +30,7 @@ import java.util.Objects; import javax.swing.InputMap; import javax.swing.JButton; import javax.swing.JComponent; +import javax.swing.JScrollBar; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -244,6 +245,11 @@ public class FlatScrollBarUI } protected void paintTrackOrThumb( Graphics g, JComponent c, Rectangle bounds, Insets insets, int arc ) { + // rotate insets for horizontal orientation because they are given for vertical orientation + if( scrollbar.getOrientation() == JScrollBar.HORIZONTAL ) + insets = new Insets( insets.right, insets.top, insets.left, insets.bottom ); + + // subtract insets from bounds bounds = FlatUIUtils.subtractInsets( bounds, UIScale.scale( insets ) ); if( arc <= 0 ) {