java.lang.ArrayIndexOutOfBoundsException: 0 >= 0 attempting to populate JTable

前端 未结 10 1620
猫巷女王i
猫巷女王i 2020-12-20 13:37

I\'m subclassing JTable and using a DefaultTableModel to model my table data. The following class sets up the JTable, and adds one row to the model.

import          


        
10条回答
  •  醉酒成梦
    2020-12-20 14:29

    Dmitry is right. Replace

    this.addColumn(ColumnName);
    this.addColumn(ColumnSize);
    this.addColumn(ColumnRmIcon);
    

    with

    Model.addColumn(ColumnName);
    Model.addColumn(ColumnSize);
    Model.addColumn(ColumnRmIcon);
    

    and now the Model knows about the columsn and won't throw an Exception anymore when you try to add a row to a model which thinks it has 0 columns

提交回复
热议问题