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. Advertisements

  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. Advertisements

  3. Nick Gusev

    prachi23

    Joined:
    Nov 18, 2014
    Messages:
    1
    Likes Received:
    0

    thanks.. the suggestion is quite helpful. The exceptions are gone however it is not refreshing tree as in UpdateUI
     
    Last edited: Nov 18, 2014
    prachi23, Nov 18, 2014
    #3
    1. Advertisements

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Tohru Kao
    Replies:
    3
    Views:
    804
    Neil Masson
    Jul 14, 2003
  2. Tohru Kao
    Replies:
    1
    Views:
    730
    Chris
    Jul 8, 2003
  3. Dhek Bhun Kho
    Replies:
    0
    Views:
    2,653
    Dhek Bhun Kho
    Jul 9, 2003
  4. Tom
    Replies:
    12
    Views:
    9,600
    Chris Smith
    Aug 5, 2003
  5. Juha Tuominen
    Replies:
    0
    Views:
    626
    Juha Tuominen
    Sep 5, 2003
  6. anonaki
    Replies:
    2
    Views:
    2,627
    anonaki
    Sep 8, 2003
  7. Alan Krueger
    Replies:
    3
    Views:
    684
    Alan Krueger
    Sep 12, 2003
  8. Replies:
    1
    Views:
    4,050
    Andrey Kuznetsov
    Dec 29, 2005
Loading...