title: How to display a JComboBox when an item is selected in another JComboBox
body: <p>I'm trying to display values in <code>JComboBox B</code> when I select items from <code>JComboBox A</code>. So far, nothing happened when I select a value from <code>JComboBox A</code>. Here is my data and code. So for instance, if I select 1 from my <code>JComboBox A</code>(paperid), my result in <code>JComboBox B</code>(authorid) will be 1,2,4.</p>
  
  <p><a href="https://i.stack.imgur.com/f9J72.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f9J72.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/bPdjj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bPdjj.png" alt="enter image description here"></a><code>JComboBox A</code></p>
  
  <p><a href="https://i.stack.imgur.com/pD9oK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pD9oK.png" alt="enter image description here"></a> <code>JComboBox B</code></p>
  
  <pre><code>private void comboboxAPopupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) { 
  
      String display = (String) comboboxA.getSelectedItem();
      String sql = "Select authorid from submission where paperid =?";
  
      try {
          ps=conn.prepareStatement(sql);
          ps.setString(1,display);
          rset = ps.executeQuery();
  
          if (rset.next()){
                 String add1 = rset.getString("authorid");
                 System.out.println(add1);
                 comboboxB.setSelectedItem(add1);
          }
  
      } catch(Exception e) {
          JOptionPane.showMessageDialog(null,e);
      }
   }
  </code></pre>