Merge PR #1030: TabbedPaneUI: When the mouse wheel event is not in the viewport, propagate the event to the nearest parent

This commit is contained in:
Karl Tauber
2025-11-29 23:25:50 +01:00
2 changed files with 9 additions and 1 deletions

View File

@@ -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

View File

@@ -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();