-
-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ArrayIndexOutOfBoundsException in FlatTabbedPaneUI #875
Comments
I am curious about your use case, are you trying to create a TabbedPane that supports 'clearing' of the selection? (no tabs selected and empty content). According to the documentation there will always be a selected tab:
|
You may be right, I didn't catch that line. I'll double check my real-life case and get back to you. |
…card" tab type and using a custom tab selection model that returns -1 for selected tab (issue #875)
fixed in latest |
I looked more closely at my real-life case and what we were doing was actually more like this:
That is, manually setting the selected index to -1. This value is set during a tab-collapse animation to indicate a changing state. Ideally I imagine I'd rewrite to not set the unexpected -1 while a tab is present, but it's pretty thorny to untangle the logic and probably not worth it at this point. I did come up with a workaround to make flatlaf 3.3 happy (sorry I forgot to report the version in my original description) until I can upgrade to 3.5.1+. I overrode getSelectedIndex() in my subclass of JTabbedPane and just don't allow it to return a negative number when there are tabs. That allows my weird animation code to function, but looks kosher to the outside world. Thanks for fixing, DevCharly. |
When a TabbedPane returns a selected index of -1, it causes a ArrayIndexOutOfBoundsException.
Linux: AlmaLinux 8.10
Gnome: Version 3.32.2
Just launch this and the window displays, but also throws this exception several times:
In FlatTabbedPaneUI.paint:
Where getSelectedIndex() returns -1 this leads to the index exception, but from the SingleSelectionModel Javadoc:
So this is a valid value for this method to return, but it is not properly handled by FlatTabbedPaneUI or BasicTabbedPaneUI.
The text was updated successfully, but these errors were encountered: