What I want is when I click subject combo box the Batch Name: combo box should change according to subject selection. I tried this but nothing happens. This code is in Subject Name: combo box action performed function.  
private void combosubjActionPerformed(java.awt.event.ActionEvent evt) {                                          
 String sub= evt.getSource().toString();
 try {
   btchcombo.removeAllItems();
   Connection conn = getConnection();
   PreparedStatement prpd = conn.prepareStatement("SELECT batch FROM BATCHLIST where subject=?");
   prpd.setString(1,sub);
   ResultSet rs = prpd.executeQuery();
   while (rs.next()) {
     String pat = rs.getString("BATCH");
     btchcombo.addItem(pat);
   }
   } catch (Exception e) {
     e.printStackTrace();
     JOptionPane.showMessageDialog(null, e);
   }    
 }                                       

 
     
     
    