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

前端 未结 10 1617
猫巷女王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:14

    From the JTable.setAutoCreateColumnsFromModel() API:

    "This method calls createDefaultColumnsFromModel if autoCreateColumnsFromModel changes from false to true. "

    Vector throws ArrayIndexOutOfBoundsException - if the index is out of range ( index < 0 || index >= size())

    I guess the table model is missing the columns, as suggested by Dmitry

提交回复
热议问题