NullPointerException in BasicTreeUI.isToggleEvent

Discussion in 'Java' started by Nick Gusev, Jun 17, 2004.

  1. Nick Gusev

    Nick Gusev Guest

    Just in case if somebody need it. I didn't find this anywhere. If you
    are getting after invoking JTree.updateUI something like:

    java.lang.NullPointerException
    at javax.swing.plaf.basic.BasicTreeUI.completeEditing(BasicTreeUI.java:1880)
    at javax.swing.plaf.basic.BasicTreeUI$TreeSelectionHandler.valueChanged(BasicTreeUI.java:2496)
    at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(DefaultTreeSelectionModel.java:629)
    at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(DefaultTreeSelectionModel.java:1076)
    at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(DefaultTreeSelectionModel.java:287)
    at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(DefaultTreeSelectionModel.java:170)
    at javax.swing.JTree.setSelectionPath(JTree.java:1168)
    at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(BasicTreeUI.java:2192)

    all you need to know that it's bad idea to update UI in order to
    refresh a tree. All pending events will be for old UI with tree ==
    null. JTree.updateUI replaces UI with new one from UIManager and calls
    JTree.invalidate. So just call JTree.invalidate instead. This should
    solve the problem.
    Nick Gusev, Jun 17, 2004
    #1
    1. Advertising

  2. Nick Gusev wrote:
    > all you need to know that it's bad idea to update UI in order to
    > refresh a tree.


    Often a need for refreshing a tree arises if the model is not firing the
    necessary change events. Instead of torturing the innocent JTree widget
    you might want to check your model implementation and behavior and fix
    it if needed.

    /Thomas
    Thomas Weidenfeller, Jun 18, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon A. Cruz

    Re: NullPointerException Error??

    Jon A. Cruz, Jul 6, 2003, in forum: Java
    Replies:
    0
    Views:
    508
    Jon A. Cruz
    Jul 6, 2003
  2. Tohru Kao
    Replies:
    3
    Views:
    417
    Neil Masson
    Jul 14, 2003
  3. Tohru Kao
    Replies:
    1
    Views:
    380
    Chris
    Jul 8, 2003
  4. Dhek Bhun Kho
    Replies:
    0
    Views:
    2,225
    Dhek Bhun Kho
    Jul 9, 2003
  5. Replies:
    1
    Views:
    3,662
    Andrey Kuznetsov
    Dec 29, 2005
Loading...

Share This Page