<Swing Dev> RfR: JDK-8133897, IndexOutOfBounds exception being thrown
Pete Brunet
peter.brunet at oracle.com
Wed Aug 19 21:50:24 UTC 2015
Please review this patch.
http://cr.openjdk.java.net/~ptbrunet/JDK-8133897/webrev.00/
The issue is that the application has a tab with a visible title but for
some reason JTabbedPane's title field was "". This caused
indexOfTab(title) to return -1 and then getTabBounds(parent, -1) raised
ArrayIndexOutOfBoundsException.
public Rectangle getBounds() {
- return parent.getUI().getTabBounds(parent,
- parent.indexOfTab(title));
+ int i = parent.indexOfTab(title);
+ Rectangle r;
+ // Check for no title. Even though that's a bug in the app
we should
+ // inhibit an ArrayIndexOutOfBoundsException from getTabBounds.
+ if (i == -1) {
+ r = null;
+ } else {
+ r = parent.getUI().getTabBounds(parent, i);
+ }
+ return r;
}
Maybe someone more familiar with the code can see a bug related to why
title is allowed to be "" when there is a visible title displayed in the
tab. The bug I am working was raised during use of an app for which we
do not have access so its source is not available.
Thanks, Pete
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20150819/aa9e17c4/attachment.html>
More information about the swing-dev
mailing list