title: Clear selection of jList
body: <p>I have a jtree an a jlist, the jlist depends of what jtree node is selected, when I selected de node colors, the jlist add two items. Then I have a jTextfield where I put the value selected in the jlist.</p>
  
  <p>My problem is when I want to select another node in jTree having a value on jlist selected.</p>
  
  <p>This is what I have in jTreeValueChanged action</p>
  
  <pre><code>private void jTree1ValueChanged(javax.swing.event.TreeSelectionEvent evt) {                                    
  
      jTextField1.setText("");
      jList1.clearSelection();
  
  
      jList1.repaint();
      //DefaultMutableTreeNode seleccion;
      seleccion=(DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
  
      if(seleccion.toString()=="colors"){
  
          jList1.setModel( model  );
          model.addElement("rojo");
          model.addElement("azul");
      }
      else if(seleccion.toString()=="sports"){
           jList1.setModel(model );
          model.addElement("futbol");
          model.addElement("beisbol");
  
      }
  
  } 
  </code></pre>
  
  <p>Now this is thew code in jListValueChanged:</p>
  
  <pre><code>private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {   
  
      String seleccion =jList1.getSelectedValue().toString();
      jTextField1.setText(seleccion);
  
  
  }  
  </code></pre>
  
  <p>There is the exception when i select the other node:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
  at navegacion.arbolconlist.jList1ValueChanged(arbolconlist.java:124)
  at navegacion.arbolconlist.access$100(arbolconlist.java:17)
  at navegacion.arbolconlist$2.valueChanged(arbolconlist.java:60)
  at javax.swing.JList.fireSelectionValueChanged(JList.java:1796)
  at javax.swing.JList$ListSelectionHandler.valueChanged(JList.java:1810)
  at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:184)
  at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:164)
  at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:211)
  at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:405)
  at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:415)
  at javax.swing.DefaultListSelectionModel.removeSelectionIntervalImpl(DefaultListSelectionModel.java:576)
  at javax.swing.DefaultListSelectionModel.clearSelection(DefaultListSelectionModel.java:420)
  at javax.swing.JList.clearSelection(JList.java:2043)
  at navegacion.arbolconlist.jTree1ValueChanged(arbolconlist.java:101)
  at navegacion.arbolconlist.access$000(arbolconlist.java:17)
  at navegacion.arbolconlist$1.valueChanged(arbolconlist.java:53)
  at javax.swing.JTree.fireValueChanged(JTree.java:2921)
  at javax.swing.JTree$TreeSelectionRedirector.valueChanged(JTree.java:3382)
  at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(DefaultTreeSelectionModel.java:635)
  at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(DefaultTreeSelectionModel.java:1093)
  at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(DefaultTreeSelectionModel.java:294)
  at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(DefaultTreeSelectionModel.java:188)
  at javax.swing.JTree.setSelectionPath(JTree.java:1633)
  at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(BasicTreeUI.java:2393)
  at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(BasicTreeUI.java:3609)
  at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(BasicTreeUI.java:3548)
  at java.awt.Component.processMouseEvent(Component.java:6524)
  at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
  at java.awt.Component.processEvent(Component.java:6292)
  at java.awt.Container.processEvent(Container.java:2234)
  at java.awt.Component.dispatchEventImpl(Component.java:4883)
  at java.awt.Container.dispatchEventImpl(Container.java:2292)
  at java.awt.Component.dispatchEvent(Component.java:4705)
  at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
  at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4530)
  at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
  at java.awt.Container.dispatchEventImpl(Container.java:2278)
  at java.awt.Window.dispatchEventImpl(Window.java:2739)
  at java.awt.Component.dispatchEvent(Component.java:4705)
  at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
  at java.awt.EventQueue.access$400(EventQueue.java:97)
  at java.awt.EventQueue$3.run(EventQueue.java:697)
  at java.awt.EventQueue$3.run(EventQueue.java:691)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
  at java.awt.EventQueue$4.run(EventQueue.java:719)
  at java.awt.EventQueue$4.run(EventQueue.java:717)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
  at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
  at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
  at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
  at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
  at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
  </code></pre>