java - Casting from JTable Object to int -



java - Casting from JTable Object to int -

i attempting retrieve value jtable , getting java.lang.nullpointer exception. next line seems issue. trying take object, 25, , cast int. reason simple task seems extremely hard or impossible. looked @ stackoverflow users question similar problem never got response worked.

the error codes read follows: exception in thread "awt-eventqueue-0" java.lang.nullpointerexception @ gradebook$5.actionperformed(gradebook.java:925)this sec line in loop.

note: edited post provide additional code.

for(int = 0; < 10; i++){ myclass[currentclass].getcategoryelement(i).setname((string)categoriestable.getmodel().getvalueat(i, 1)); myclass[currentclass].getcategoryelement(i).setweight(integer.valueof((string)(categoriestable.getmodel().getvalueat(i, 2))));//this line identified problem } categoriestable.setmodel(new defaulttablemodel( new object[][] { {"1", "classwork", "20"}, {"2", "homework", "20"}, {"3", "tests", "20"}, {"4", "quizzes", "20"}, {"5", "projects", "20"}, {"6", null, null}, {"7", null, null}, {"8", null, null}, {"9", null, null}, {"10", null, null}, },

thank helping me. used if statement check null values though i'm still not sure why didn't need same thing first statement in loop.

java swing casting jtable int

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -