changeset 32483:851c672880a6

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
author ptbrunet
date Thu, 20 Aug 2015 13:00:19 -0500
parents 45ff83ee1ee9
children e07799997e1f
files jdk/src/java.desktop/share/classes/javax/swing/JTabbedPane.java
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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) {