title: Java Swing drop down list
body: <p>I have created a drop down list using JAVA Swing. When I select "Keep track of status of RCM:", I want to create another drop down list next to the option selected. should I use mouseactionlistener instead?   I trying to accomplish something like in this, when I click menu options, there is another list which I can select under menu options category.  Example : <a href="http://smoothjazztampabay.com/wp-content/rockettheme/rt_metropolis_wp/menu-options/dropdownmenu.jpg" rel="nofollow">http://smoothjazztampabay.com/wp-content/rockettheme/rt_metropolis_wp/menu-options/dropdownmenu.jpg</a></p>
  
  <p>I tried using this code but couldn't.</p>
  
  <pre><code>         if (state == ItemEvent.SELECTED)
          {
              ItemSelectable itemS = itemEvent.getItemSelectable();
              String cmd = selectedString(itemS);
              if ( cmd.equals("Keep track of status of RCM:"))
              {
                  RCMCombo2.addItem(RCMCombo);
                  selectionPanel.add(RCMCombo2);
              }
  </code></pre>
  
  <p>The full version of the code is shown as below:</p>
  
  <pre><code>    String [] RCM2 = {"Keep track of status of RCM:", "Add and activate RCM", "Remove RCM", 
       "Display the usage statistics for RCM", 
  "Update capabilities of RCMs", "Show RCM used most frequently in the last n days",
  "Display number of times the RCM was emptied in n hours"};
  
  
  RCMCombo2 = new JComboBox(RCM2); 
  RCMCombo2.addItemListener(itemListener);  
      RCMCombo2.setEditable(false);
      RCMCombo2.setBounds(10,10,10,30);
  
      //"Updates capabilities of RCM"); Get the location of RCM");
  
      selectionPanel.add(RCMCombo2);
  
  ItemListener itemListener = new ItemListener() 
  {
        public void itemStateChanged(ItemEvent itemEvent) 
        {
          int state = itemEvent.getStateChange();
          //System.out.println((state == ItemEvent.SELECTED) ? "Selected" : "Deselected");
          //System.out.println("Item: " + itemEvent.getItem());
          if (state == ItemEvent.SELECTED)
          {
              ItemSelectable itemS = itemEvent.getItemSelectable();
              String cmd = selectedString(itemS);
              if ( cmd.equals("Keep track of status of RCM:"))
              {
                  RCMCombo2.addItem(RCMCombo2);
                  selectionPanel.add(RCMCombo2);
              }
  </code></pre>
  
  <p>Any help will be appreciated. Thank you.</p>