I keep getting this NPE in my application and I can’t seem to get rid of it because it is not showing up in any of my source code. As you can see from the stacktrace it is not happening in my code but in the Swing plaf. Has any of you had this problem and maybe figured out what is happening here?
11:28:23,273 [AWT-EventQueue-0] ERROR [is.althingi.styran.utlit.styran.StyranImpl] - uncaughtException java.lang.NullPointerException at javax.swing.plaf.basic.BasicTableUI$Handler.setValueIsAdjusting(Unknown Source) at javax.swing.plaf.basic.BasicTableUI$Handler.mouseReleased(Unknown Source) at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
I managed to get around the problem!
The thing is that I add a
ListSelectionListenerto myJTable; in thevalueChangedmethod of my listener I then callscrollRectToVisibleand thenupdateUI, which then results in my exception.What I did was to add
invokeLateraround theupdateUIcall and no more exception!Like this:
Now that I have the ‘answer’ to my question (though I’m not sure I still understand why the
invokeLaterhelped?), I think my question wasn’t good enough. I didn’t provide enough information about my problem for anyone to be able to answer the question. Should I have researched the problem more before I asked? I don’t know.Maybe it is enough that I provide the solution that helped me!