Getting jcombobox selected item
<p>i have this code and i want to get the selected item from jcombobox,but when i run my project it gives me duplication print of the value of the selected item and  java.Lang.NullPointerException
Here is the code :</p>

<pre><code> private void jComboBox4ItemStateChanged(java.awt.event.ItemEvent evt) {                                            
        // TODO add your handling code here:
         if (evt.getStateChange()==ItemEvent.SELECTED){

             String a=String.valueOf(jComboBox4.getSelectedItem());
         System.out.print(a);

         try{
        String del2="select distinct PTYPE from Projects inner join project on projects.PNUMBER=(select pro_id from project where pro_name='"+a+"')";
         psst=con.prepareStatement(del2);
        String td2;
          DefaultComboBoxModel mode2 = new DefaultComboBoxModel();
           ResultSet rss=psst.executeQuery();
           while(rss.next()){
            td2=rss.getString("PTYPE");
    mode2.addElement(td2);
       jComboBox7.setModel(mode2);
           }
    }
        catch(SQLException ex){
            JOptionPane.showMessageDialog(null, ex.toString());
 } 
}
</code></pre>