I recently added TreeWillExpandListener to my JTree, to be sued to prevent the expansion of a certain directory within the JTree. This part of the code work alright, but when something is deleted in the JTree, the code throws the following maojor exception:
Exception in
thread "AWT-EventQueue-0" java.lang.NullPointerException
at film_titles.poster_manager.DocumentTree.treeWillExpand(Unknown Source)
at javax.swing.JTree.fireTreeWillExpand(JTree.java:2723)
at javax.swing.JTree.setExpandedState(JTree.java:3421)
at de.schlichtherle.io.swing.JFileTree.setExpandedDescendants(JFileTree.java:394)
at de.schlichtherle.io.swing.JFileTree.refresh(JFileTree.java:381)
at de.schlichtherle.io.swing.JFileTree.refresh(JFileTree.java:337)
at film_titles.poster_manager.DocumentTree$3.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
When I remove the code with the method below, the exception no longer appears. When I try to
test for a null value on the second line of the method, the exception still appears.
if(DocumentTree.this.getLastSelectedPathComponent().toString() == null)