<Swing Dev> [9] Review request for JDK-7170310: ScrollBar doesn't become active when tabs are created more than frame size

Alexey Ivanov alexey.ivanov at oracle.com
Wed Oct 8 11:57:45 UTC 2014


Hello Swing team,

Could you please review the fix for the bug:
     bug: https://bugs.openjdk.java.net/browse/JDK-7170310
     webrev: http://cr.openjdk.java.net/~aivanov/7170310/jdk9/webrev.0/

Description:
If you add more tabs to JTabbedPane than a frame can fit, scrolling 
buttons are not enabled, and users have no way to switch to hidden tabs 
until they click another tab.

The test scenario is to add a new tab and select it right away.

Root cause:
Scrolling is not handled properly in this case because 
JTabbedPane.addTab invalidated the component. Method setSelectedIndex 
scrolls the active tab into view but the location of the new added tab 
is not available yet.

The fix:
Invalidate the view of JViewport to ensure its size is set to its 
preferred size during validation. Then stateChanged listener ensures the 
layout is valid before scrolling the tabs view.

I created a new automatic test for this issue.
I ran all JTabbedPane regression tests and they passed.

Thank you in advance,
Alexey.



More information about the swing-dev mailing list