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

JTable(1, 0) constructor throws ArrayIndexOutOfBoundsException.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      Name: aaC67449 Date: 08/18/99




      The JTable(1, 0) constructor throws ArrayIndexOutOfBoundsException, but
      should create a table with one row and no columns.

      javadoc says:"
      public JTable(int numRows,
                    int numColumns)

            Constructs a JTable with numRows and numColumns of empty cells using
      the
            DefaultTableModel. The columns will have names of the form "A", "B",
      "C", etc.
            Parameters:
                  numRows - the number of rows the table holds
                  numColumns - the number of columns the table holds
            See Also:
                  DefaultTableModel
      "

      See example.
      ------------- example --------------
      import javax.swing.JTable;

      public class Test {

         public static void main(String argv[]) {
             JTable c = new JTable (1,0);
         }

      }

      ------------- JDK1.3beta output ---------------
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
              at java.util.Vector.elementAt(Vector.java:409)
              at
      javax.swing.table.DefaultTableColumnModel.getColumn(DefaultTableColumnModel.java:267)
              at javax.swing.JTable.getCellRect(JTable.java:1780)
              at javax.swing.JTable.columnSelectionChanged(JTable.java:2727)
              at
      javax.swing.table.DefaultTableColumnModel.fireColumnSelectionChanged(DefaultTableColumnModel.java:509)
              at
      javax.swing.table.DefaultTableColumnModel.valueChanged(DefaultTableColumnModel.java:575)
              at
      javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:149)
              at
      javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:130)
              at
      javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:176)
              at
      javax.swing.DefaultListSelectionModel.setAnchorSelectionIndex(DefaultListSelectionModel.java:538)
              at javax.swing.JTable.initializeLocalVars(JTable.java:3115)
              at javax.swing.JTable.<init>(JTable.java:364)
              at javax.swing.JTable.<init>(JTable.java:308)
              at javax.swing.JTable.<init>(JTable.java:378)
              at Test.main(Test.java:7)


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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: