Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tablemodel getcolumnclass() method produces null pointer exception

 
Simon Knight
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi - i'm trying to load results from an oracle database into a JTable with a button in each row. Unfortunately, I'm having some difficulty with the getColumnClass which I understand is supposed to tell the JTable how to render the data contained in the column, which in this instance should be JButtons. The code below compiles ok:



but when the tablemodel is used in the JTable like



or like



running the main class results in a null pointer exception - thus:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at dbforensicanalysistool.SQLTableModel.getColumnClass(SQLTableModel.java:74)


I can't work out why!!?? Can anyone help?
 
Maneesh Godbole
Saloon Keeper
Posts: 11185
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are getting the null pointer because the value Object returned by getValueAt is null. I have encountered this problem before, though I have not been able to figure out why it is caused.

This is the workaround:
 
Simon Knight
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are a lifesaver - thankyou!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic