title: How to scroll this panel of radio buttons
body: <p>I am new to swing. I might use a layout manager one day, but please just advise on how I can add a vertical scroll bar to my <code>Frame</code>. I have taken an unorthodox approach, I realize, but I'm learning. I am totally stumped, having read the API. How I would go about adding a vertical scroll bar to the following <code>JFrame</code>?</p>
  
  <p><a href="https://i.stack.imgur.com/lra9S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lra9S.png" alt="enter image description here"></a></p>
  
  <p>My code snippet is as follows :</p>
  
  <pre><code>import javax.swing.JScrollPane;
  import java.awt.event.*;
  import javax.swing.*;  
  import javax.swing.JOptionPane;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  //import java.util.Arrays;
  
  public class NewGameGUI implements ActionListener
  { 
    private final JRadioButton[] rb = new JRadioButton[20];
      JFrame f3;  
      JButton b;
      JLabel label1; 
      public NewGameGUI()
      {  
          label1 = new JLabel("Please choose a team");
          f3 = new JFrame("Ballon d'or");  
          f3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          rb[0] = new JRadioButton("Arsenal");  
          rb[1] = new JRadioButton("Aston Villa");
          rb[2] = new JRadioButton("Bournemouth");
          rb[3] = new JRadioButton("Chelsea");
          rb[4] = new JRadioButton("Crystal Palace");
          rb[5] = new JRadioButton("Everton");
          rb[6] = new JRadioButton("Leicester City");
          rb[7] = new JRadioButton("Liverpool");
          rb[8] = new JRadioButton("Manchester United");
          rb[9] = new JRadioButton("Manchester City");
          rb[10] = new JRadioButton("Newcastle United");
          rb[11] = new JRadioButton("Norwich City");
          rb[12] = new JRadioButton("Southampton");
          rb[13] = new JRadioButton("Stoke City");
          rb[14] = new JRadioButton("Sunderland");
          rb[15] = new JRadioButton("Swansea City");
          rb[16] = new JRadioButton("Tottenham Hotspur");
          rb[17] = new JRadioButton("Watford");
          rb[18] = new JRadioButton("West Brom");
          rb[19] = new JRadioButton("West Ham");
  
          label1.setBounds(50,25,200,30);
          f3.add(label1);
  
          rb[0].setBounds(50,75,170,30);  
          rb[1].setBounds(50,100,170,30);  
          rb[2].setBounds(50,125,170,30);
          rb[3].setBounds(50,150,170,30);
          rb[4].setBounds(50,175,170,30);
          rb[5].setBounds(50,200,170,30);
          rb[6].setBounds(50,225,170,30);
          rb[7].setBounds(50,250,170,30);
          rb[8].setBounds(50,275,170,30);
          rb[9].setBounds(50,300,170,30);
          rb[10].setBounds(50,325,170,30);
          rb[11].setBounds(50,350,170,30);
          rb[12].setBounds(50,375,170,30);
          rb[13].setBounds(50,400,170,30);
          rb[14].setBounds(50,425,170,30);
          rb[15].setBounds(50,450,170,30);
          rb[16].setBounds(50,475,170,30);
          rb[17].setBounds(50,500,170,30);
          rb[18].setBounds(50,525,170,30);
          rb[19].setBounds(50,550,170,30);
  
         // JScrollPane pane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  
         // f3.setContentPane(pane);
  
          ButtonGroup bg=new ButtonGroup();  
          bg.add(rb[0]);
          bg.add(rb[1]);
          bg.add(rb[2]);  
          bg.add(rb[3]); 
          bg.add(rb[4]); 
          bg.add(rb[5]); 
          bg.add(rb[6]); 
          bg.add(rb[7]); 
          bg.add(rb[8]); 
          bg.add(rb[9]); 
          bg.add(rb[10]); 
          bg.add(rb[11]); 
          bg.add(rb[12]); 
          bg.add(rb[13]); 
          bg.add(rb[14]);
          bg.add(rb[15]);
          bg.add(rb[16]);
          bg.add(rb[17]);
          bg.add(rb[18]);
          bg.add(rb[19]);
  
          b = new JButton("OK");
          b.setBounds(300,300,180,30);  
          b.addActionListener(this);
          f3.add(rb[0]);
          f3.add(rb[1]);
          f3.add(rb[2]);
          f3.add(rb[3]);
          f3.add(rb[4]);
          f3.add(rb[5]);
          f3.add(rb[6]);
          f3.add(rb[7]);
          f3.add(rb[8]);
          f3.add(rb[9]);
          f3.add(rb[10]);
          f3.add(rb[11]);
          f3.add(rb[12]);
          f3.add(rb[13]);
          f3.add(rb[14]);
          f3.add(rb[15]);
          f3.add(rb[16]);
          f3.add(rb[17]);
          f3.add(rb[18]);
          f3.add(rb[19]);
          f3.add(b);
  
          f3.setSize(700,700);  
  
          f3.setLayout(null);  
          f3.setVisible(true);  
      }
  
      public void setFrame(JFrame f3){
          this.f3 = f3;
      }
      public JFrame getFrame(){
  
      return f3;
      }
              public void actionPerformed(ActionEvent e)
              {  
                  if(rb[0].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[0].getText());  
                  }  
                  if(rb[1].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[1].getText()); 
                  } 
                  if(rb[2].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[2].getText()); 
                  }  
                  if(rb[3].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[3].getText()); 
                  }
                  if(rb[4].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[4].getText()); 
                  }
                  if(rb[5].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[5].getText()); 
                  }
                  if(rb[6].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[6].getText()); 
                  }
                  if(rb[7].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[7].getText()); 
                  }
                  if(rb[8].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[8].getText()); 
                  }
                  if(rb[9].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[9].getText()); 
                  }
                  if(rb[10].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[10].getText()); 
                  }
                  if(rb[11].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[11].getText()); 
                  }
                  if(rb[12].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[12].getText()); 
                  }
                  if(rb[13].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[2].getText()); 
                  }
                  if(rb[14].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[14].getText()); 
                  }
                  if(rb[15].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[15].getText()); 
                  }
                  if(rb[16].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[16].getText()); 
                  }
                  if(rb[17].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[17].getText()); 
                  }
                  if(rb[18].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[18].getText()); 
                  }
                  if(rb[19].isSelected())
                  {
                     f3.dispose();
                     JOptionPane.showMessageDialog(f3,"You chose : " + rb[19].getText()); 
                  }  
              }
  }
  </code></pre>