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:

    at javax.swing.plaf.basic.BasicTreeUI.completeEditing(
    at javax.swing.plaf.basic.BasicTreeUI$TreeSelectionHandler.valueChanged(
    at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(
    at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(
    at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(
    at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(
    at javax.swing.JTree.setSelectionPath(
    at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(

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

  2. 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 Weidenfeller, Jun 18, 2004
    1. Advertisements

  3. Nick Gusev


    Nov 18, 2014
    Likes Received:

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

Ask a Question

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.