Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4255146

JTableHeader.getHeaderRect(-1) throws ArrayIndexOutOfBoundsException

XMLWordPrintable

    • kestrel
    • sparc
    • solaris_2.5.1



      Name: aaC67449 Date: 07/19/99



      The JTableHeader.getHeaderRect(-1) throws an ArrayIndexOutOfBoundsException in the jdk1.3

      jdk1.3 docs:"
      public Rectangle getHeaderRect(int column)

            Returns the rectangle containing the header tile at column.
            Returns:
                  the rectangle containing the header tile at column
            Throws:
                  Exception - If column is out of range
      "

      But It throws an IllegalArgumentException in the jdk1.2.2

      jdk1.2.2 docs:"
      public Rectangle getHeaderRect(int columnIndex)

            Returns the rectangle containing the header tile at columnIndex.
            Returns:
                  the rectangle containing the header tile at columnIndex
            Throws:
                  IllegalArgumentException - If columnIndex is out of range
      "


      This is incompatible change and the behavior of the method should be restored.

      -------------example -------------
      import javax.swing.table.JTableHeader;

      public class Test {
          public static void main(String argv[]) {
       
          JTableHeader c=new JTableHeader(); // Create ' . $class . ' object
          
           try {
               c.getHeaderRect(-1);
               System.out.println( "Method does not throw IllegalArgumentException"
      );
           } catch(IllegalArgumentException e) { }
              System.out.println("Passed");
          }
      }

      -------------JDK-1.3-K output ---------------
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 < 0
              at java.util.Vector.elementAt(Vector.java, Compiled Code)
              at javax.swing.table.DefaultTableColumnModel.getColumn(DefaultTableColumnModel.java, Compiled Code)
              at javax.swing.table.JTableHeader.getHeaderRect(JTableHeader.java, Compiled Code)
              at Test.main(Test.java, Compiled Code)

      -------------jdk1.2.2 output ---------------
      Passed


      ======================================================================

            pmilnesunw Philip Milne (Inactive)
            alisunw Ali Ali (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: