• 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

Not able to rectify the swing Exception

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,
I am populating an JTable with some information. everything works fine but while populating table am getting following exception(still am able to populate table correctly)

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.plaf.basic.BasicTableHeaderUI.paintCell(BasicTableHeaderUI.java:394)

what could be the reason for this exception. and how to rectify the same?

thanks in advance!
Sachin!!!
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once you go into GUIs you get several threads; you may crash a Thread with an Exception and still have the display on screen.
NullPointerExceptions are a standard beginner's problem. The hardest part is finding what causes them. Get a full stack trace for your Exception and find the first line in your code where it occurs. Look through every object in that line; you have done one of the following things:
  • Declared it and forgotten to instantiate it,
  • set it to null,
  • or lost it and forgotten to re-instantiate it.
  • If you can't work out which it is, insert a test line one line before where it happens rather like this:-If you get a lot of incomprehensible writing on screen, assume your object exists; if it doesn't the word "null" will appear. Find where you were supposed to instantiate that object and do so.

    This exception appears very frequently; you will find lots more about it on these fora if you do a search.
     
    Sachin Dimble
    Ranch Hand
    Posts: 100
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    well it's resolved!!! i implemented the swing worker thread while populating the Jtable, now my application is migrated to -
    java version "1.6.0_01"
    Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
    Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing

    now when i click on coloumn of Jtable for sorting the rows am getting the same exception. since these exception is in api code itself i can't debug it by printing the objects which are going null.
    How shall i supress this exception?

    Thanks,
    Sachin.
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic