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

DefaultTableModel.addColumn() does not accept too long columns.

XMLWordPrintable



      Name: aaR10142 Date: 06/26/2000



      DefaultTableModel.addColumn(name, column) does not accept too long column,
      in jdk1.4, it looks like a bug because it accept short column. See example.

      All works correctly in jdk1.3

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

      public class Test {

          public static void main(String argv[]) {
              DefaultTableModel c = new DefaultTableModel(2,2);
              
              // add short column
              c.addColumn("Test", new Object[1]);
              System.out.println("The short column is accepted");

              // add long column
              c.addColumn("Test", new Object[3]);
              System.out.println("The long column is accepted");
           }

      }

      ------------------------- jdk1.4 output ----------------
      The short column was accepted
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 >= 2
              at java.util.Vector.elementAt(Vector.java:417)
              at javax.swing.table.DefaultTableModel.addColumn(DefaultTableModel.java:522)
              at javax.swing.table.DefaultTableModel.addColumn(DefaultTableModel.java:542)
              at Test.main(Test.java:13)

      ------------------------- jdk1.3 output ----------------
      The short column is accepted
      The long column is accepted


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

            svioletsunw Scott Violet (Inactive)
            alisunw Ali Ali (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: