indexoutofboundsexception - Java- adding a new row to a JTable in GUI -
indexoutofboundsexception - Java- adding a new row to a JTable in GUI -
i have simple java gui displaying empty table , few buttons. trying add together listener 1 of buttons add together new empty row (with editable cells) table in gui.
i using next code seek , this:
jbutton addbtn = new jbutton("add"); addbtn.addactionlistener(new actionlistener(){ public void actionperformed(actionevent e){ system.out.println("'add' button pressed. "); defaulttablemodel model = (defaulttablemodel)jentityfiltertable.getmodel(); model.addrow(new object[]{"site", "application", "entity"}); system.out.println("--- actionlistener added 'addbtn' ---"); } });
however, when click button, getting java.lang.arrayindexoutofboundsexception
. says occurring on next line:
model.addrow(new object[]{"site", "application", "entity"});
i not sure why i'm getting exception... i've created new object[]
array, , given 3 elements... i'm not trying access elements (or elements don't exist)...
can point out i'm doing wrong here?
i think work
defaulttablemodel model = (defaulttablemodel) jentityfiltertable.getmodel(); vector row = new vector(); row.add("site"); row.add("application"); row.add("entity"); model.addrow(row);
java indexoutofboundsexception
Comments
Post a Comment