8133897: IndexOutOfBounds exception being thrown
Summary: In JTabbedPane.Page.getBounds return null when indexOfTab returns -1
Reviewed-by: azvegint, alexsch
Contributed-by: peter.brunet@oracle.com
--- a/jdk/src/java.desktop/share/classes/javax/swing/JTabbedPane.java Thu Aug 20 13:46:16 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JTabbedPane.java Thu Aug 20 13:00:19 2015 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -2304,8 +2304,10 @@
}
public Rectangle getBounds() {
- return parent.getUI().getTabBounds(parent,
- parent.indexOfTab(title));
+ int i = parent.indexOfTab(title);
+ // Check for no title. Even though that's a bug in the app we should
+ // inhibit an ArrayIndexOutOfBoundsException from getTabBounds.
+ return (i == -1) ? null : parent.getUI().getTabBounds(parent, i);
}
public void setBounds(Rectangle r) {