title: How to use the JScrollPane in Java
body: <p>How can I get the scroller around my JList component in the code given below? It doesn't seem to work properly :(</p>
  
  <pre><code> public class JButtonO extends JFrame{
  
  String[] values = {"henry", "Michael","Uche","John","Ullan","Nelly",
                                "Ime","Lekan","Austine","jussi","Ossi","Imam","Empo","Austine","Becky",
                               "Scholar","Ruth", "Anny"};
  
   public JButtonO()
  {
     super("the button");
     this.setSize(400,200);
     JPanel panel =  new JPanel();
     JLabel label = new JLabel("Output Items:");
     label.setAlignmentX(1);
     label.setAlignmentY(1);
     JList conList = new JList(values);
     conList.setVisibleRowCount(3);
     JScrollPane scroller = new JScrollPane(conList);
     panel.add(label);
     panel.add(scroller);
     panel.add(conList);
  
     this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     this.add(panel);
     this.setVisible(true);
  
  
  }
  </code></pre>