Why do I keep getting NullPointerException in Java BasicTableUI $ Handler.setValueIsAdjusting?

I keep getting this NPE in my application and I can't get rid of it because it doesn't show up in any of my source codes. As you can see from the stacktrace, this does not happen in my code, but in the Swing plugin. Have any of you had this problem and perhaps figured out what's going on 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)

      

+1


source to share


2 answers


I managed to solve the problem!

The point is that I add ListSelectionListener

to mine JTable

; in the method of valueChanged

my listener, I then call scrollRectToVisible

and then updateUI

, which then results in my exception.

I did to add invokeLater

around the call updateUI

and more exceptions !

Like this:



  SwingUtilities.invokeLater(new Runnable() {
    public void run() {
      updateUI();
    }
  });

      

Now that I have an "answer" to my question (although I'm not sure if I still understand why it helped invokeLater

), I think my question was not good enough. I have not provided enough information about my problem for anyone to answer this question. Should I research the issue more before I asked? I dont know.

Perhaps enough for me to provide a solution that helped me!

+8


source


I never had this particular problem, but when I get such "hidden" errors I always end up looking for the source code and try to figure out the problem ...

From this source, you can see the function that comes from the exception:



private void setValueIsAdjusting(boolean flag) {
    table.getSelectionModel().setValueIsAdjusting(flag);
    table.getColumnModel().getSelectionModel().
    setValueIsAdjusting(flag);
}

      

Can you confirm if your model is table selection; column model; column selection model is not null?

+2


source







All Articles