title: filling combo box on radio button select
body: <p>1.0 
  I'm filling combobox on checkbox checked
  depends on wihich genre you choose combobox should display options
  Worked for a while but than I did something and now it only displays one option a displays it only when unchecking the checkbox
  Is there better way to do this ?</p>
  
  <p>UPDATE 1.1: 
   Okay I updated the code. Deleted all unnecessary I hope.
  I tryied with ItemListener and ActionListener.
  But I think that's not problem, I think that I'm filling the JCOmboBox somehow wrong.
  It's somewhere around   <code>jcboCountry.removeAllItems();</code>  this makes mess I think.
  I even try to write method <code>empty();</code> to delete one by one but it still fills my JCB only with one item. Also the radio buttons sometimes don't check when I click on them. And sometimes it files the JCB on second click on RadioButton.</p>
  
  <pre><code>public class FinalPlayer extends JApplet implements ActionListener, ItemListener{
  
  JPanel westP = new JPanel();
  JPanel centerP = new JPanel();
  JPanel bottomP = new JPanel();
  
  
  JPanel genresP = new JPanel();
  JPanel imagePanel = new JPanel();
  JPanel countryPanel = new JPanel();
  JComboBox jcboCountry = new JComboBox();
  
  JTextField genreF = new JTextField();
  
  String country;
  
  
  JRadioButton jazzCB = new JRadioButton("Pop",true);
  JRadioButton rockCB = new JRadioButton("Rock",false);
  JRadioButton allCB = new JRadioButton("All",false);
  ButtonGroup bG = new ButtonGroup();
  
  
  /** Initialize the applet */
  public void init() {
  
      Container contentPane = getContentPane();  
      mainPanel.setPreferredSize( new Dimension(701, 341));
  
      topP.setPreferredSize( new Dimension(700, 30));       
      eastP.setPreferredSize( new Dimension(225,280));        
      centerP.setPreferredSize( new Dimension(250,280));       
      westP.setPreferredSize( new Dimension(225,280));        
      bottomP.setPreferredSize( new Dimension(700, 30));
  
      // TOP
  
      //WEST
  
      genreF.setPreferredSize( new Dimension(124, 29));
      genreF.setEditable(false);  
      genreF.setText("Choose Genre");
      genresP.setPreferredSize( new Dimension(124, 250));
      jazzCB.setPreferredSize( new Dimension(123, 19));
      rockCB.setPreferredSize( new Dimension(123, 19));
      allCB.setPreferredSize( new Dimension(123, 19));
      bG.add(jazzCB);
      bG.add(rockCB);
      bG.add(allCB);
  
      //jazzCB.addItemListener(this);
      //rockCB.addItemListener(this);
      //allCB.addItemListener(this);
  
  
      jazzCB.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                  empty();
                  //jcboCountry.removeAllItems();
  
                  jcboCountry.addItem("Bastille - Pompeii");
                  jcboCountry.addItem("Imagine Dragons - Tiptoe");
                  jcboCountry.addItem("John Legend - All of me");
                  jcboCountry.addItem("Katy Perry - Dark horse");
  
              }
          });
  
      rockCB.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                  empty();
                  //jcboCountry.removeAllItems();
  
                  jcboCountry.addItem("Red Hot Chilly Peppers - By the way");
                  jcboCountry.addItem("Red Hot Chilly Peppers - Californication");
                  jcboCountry.addItem("Red Hot Chilly Peppers - Dani California");
                  jcboCountry.addItem("Red Hot Chilly Peppers - Under the Bridge");
  
              }
          });
  
      allCB.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                  empty();
                  //jcboCountry.removeAllItems();
  
                  jcboCountry.addItem("Bastille - Pompeii");
                  jcboCountry.addItem("Imagine Dragons - Tiptoe");
                  jcboCountry.addItem("John Legend - All of me");
                  jcboCountry.addItem("Katy Perry - Dark horse");
                  jcboCountry.addItem("Red Hot Chilly Peppers - By the way");
                  jcboCountry.addItem("Red Hot Chilly Peppers - Californication");
                  jcboCountry.addItem("Red Hot Chilly Peppers - Dani California");
                  jcboCountry.addItem("Red Hot Chilly Peppers - Under the Bridge");
  
              }
          });
      genresP.add(jazzCB);
      genresP.add(rockCB);
      genresP.add(allCB);
  
  
      //CENTER
      imagePanel.setPreferredSize( new Dimension(249, 249));
      descF.setPreferredSize( new Dimension(249, 30));
      descF.setEditable(false);  
      descF.setText("Descriptio");
  
      //EAST
  
  
      //BOTTOM
      countryPanel.setPreferredSize( new Dimension(249, 50));
      countryPanel.add(jcboCountry);
      jcboCountry.addItemListener(this);
      //jcboCountry.setEnabled(false);
  
      // FILLING 
  
  
      centerP.add(descF, BorderLayout.NORTH);
      centerP.add(imagePanel, BorderLayout.CENTER);
      westP.add(genreF ,BorderLayout.NORTH);
      westP.add(genresP ,BorderLayout.CENTER);
      bottomP.add(countryPanel, BorderLayout.CENTER);
  
  
      mainPanel.add(westP, BorderLayout.WEST);
      mainPanel.add(centerP, BorderLayout.CENTER);
  
      mainPanel.add(bottomP, BorderLayout.SOUTH);
      contentPane.add( mainPanel);
  }
  
  public void empty(){
      int itemCount = jcboCountry.getItemCount();
  
      for(int i=0;i&lt;itemCount;i++){
          jcboCountry.removeItemAt(0);
      }
   }
  
  
   public void itemStateChanged(ItemEvent e) 
   {  
      /* Object source = e.getSource();
  
      if (source == jazzCB) {
      jcboCountry.removeAllItems();
      jcboCountry.addItem("Bastille - Pompeii");
      jcboCountry.addItem("Imagine Dragons - Tiptoe");
      jcboCountry.addItem("John Legend - All of me");
      jcboCountry.addItem("Katy Perry - Dark horse");
  
      }
      if (source == rockCB){
      jcboCountry.removeAllItems();
      jcboCountry.addItem("Red Hot Chilly Peppers - By the way");
      jcboCountry.addItem("Red Hot Chilly Peppers - Californication");
      jcboCountry.addItem("Red Hot Chilly Peppers - Dani California");
      jcboCountry.addItem("Red Hot Chilly Peppers - Under the Bridge");
  
      }   
      if (source == allCB){
      jcboCountry.removeAllItems();
      jcboCountry.addItem("Bastille - Pompeii");
      jcboCountry.addItem("Imagine Dragons - Tiptoe");
      jcboCountry.addItem("John Legend - All of me");
      jcboCountry.addItem("Katy Perry - Dark horse");
      jcboCountry.addItem("Red Hot Chilly Peppers - By the way");
      jcboCountry.addItem("Red Hot Chilly Peppers - Californication");
      jcboCountry.addItem("Red Hot Chilly Peppers - Dani California");
      jcboCountry.addItem("Red Hot Chilly Peppers - Under the Bridge");
  
      }*/
    }  
  
  
  
  /** Main method */
  public static void main(String[] args) {
      JFrame frame = new JFrame("Display Flags and Play Anthem");
      FinalPlayer applet = new FinalPlayer();
      frame.getContentPane().add(applet, BorderLayout.CENTER);
  
      applet.init();
      applet.start();
      frame.setTitle("My Media Player ");
      frame.setResizable(false);
      // Display the frame
      frame.pack();
      frame.setVisible(true);
    }
   }
  </code></pre>