• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

tablemodel getcolumnclass() method produces null pointer exception

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are a lifesaver - thankyou!
 
reply
    Bookmark Topic Watch Topic
  • New Topic