RFR: 6286501: JTabbedPane throws NPE from its stateChanged listener in particular case

Jayathirth D V jdv at openjdk.org
Thu Sep 15 06:03:43 UTC 2022


On Thu, 8 Sep 2022 09:46:03 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> JTabbedPane throws NPE from its stateChanged listener as it tries to access uninstantiated TabbedPane.
> Fix is to use the tabPane passed to stateChangeListener so that correct tabPane is accessed.

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java line 4102:

> 4100:             setFocusIndex(tabPane.getSelectedIndex(), false);
> 4101: 
> 4102:             if (tabPane.getLayout() instanceof TabbedPaneScrollLayout) {

I see BasicTabbedPaneUI.tabPane object getting used in other listeners in this Handler class. Is there a reason why only when we hit stateChanged() function we are seeing NPE?

Is this NPE for tabPane object itself or Layout not being initialized?

-------------

PR: https://git.openjdk.org/jdk/pull/10216



More information about the client-libs-dev mailing list