can't identify the error in java program
This question already has an answer here:
As per exception error is at line 57 ie table.setModel(null);
And this is because you are initializing table at line 62 [table = new JTable();] and using it before that at line 57.
It is a basic exception you face many time when you have null values in objects.
Check for any null objects in your program.
maybe 57th line in your class.
java.lang.NullPointerException at jtabledemo.Accounts.(Accounts.java:57) at
add table=new JTable(model);
before using table object.
you declare instance private JTable table;
but not initialize.(default value of instance object is null).So that's why you are getting nullpointerexception
And also you need to make final DefaultTableModel model=new DefaultTableModel();
and final Object[] row=new Object[2];
final because local variable model and row is accessed from within inner class; needs to be declared final
上一篇: 使用jquery将javascript添加到html页面中
下一篇: 无法识别Java程序中的错误