diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d20ae1d..e5f3063e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ FlatLaf Change Log - TabbedPane: Added icon-only tab mode, which shows tab icons but hides tab titles. Tab titles are used in "Show Hidden Tabs" popup menu. (set client property `JTabbedPane.tabWidthMode` to `"iconOnly"`) +- TabbedPane: In scroll tab layout, propagate mouse wheel events to ancestors. + This allows mouse wheel scrolling if JTabbedPane is inside a JScrollPane. (PR + #1030) #### Fixed bugs 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 07a4c124..4b76f715 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 @@ -2718,8 +2718,13 @@ debug*/ // because this listener receives mouse events for the whole tabbed pane, // we have to check whether the mouse is located over the viewport - if( !isInViewport( e.getX(), e.getY() ) ) + if( !isInViewport( e.getX(), e.getY() ) ) { + // if it is not in the viewport, retarget the event to a parent container + // which might support scrolling (e.g. a surrounding ScrollPane) + Container parent = tabPane.getParent(); + parent.dispatchEvent( SwingUtilities.convertMouseEvent( tabPane, e, parent ) ); return; + } lastMouseX = e.getX(); lastMouseY = e.getY();