Null pointer exception in a swing component

Stack trace:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at javax.swing.plaf.basic.BasicTableUI.paintCell(
        at javax.swing.plaf.basic.BasicTableUI.paintCells(
        at javax.swing.plaf.basic.BasicTableUI.paint(

In my case, this happened because I was updating this swing component from a separated thread. A way to avoid this is to wait to all pending AWT events to be processed. This can be done with SwingUtilities.invokeLater.

SwingUtilities.invokeLater(new Runnable(){
    void doRun(){
        // code that updates the component

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s