title: My program isn't creating expected JButtons in action handler
body: <p>The following Java program attempts to read data from a database, but instead of creating the multiple buttons I expect to be the result of the <code>while()</code> loop, I only get one button whose title is the first database entry. Can anyone help me determine why?</p>
  
  <pre><code> // Submit button's action handler
  
  btnSubmit.addActionListener(new ActionListener() {
  
          public void actionPerformed(ActionEvent e) 
              JFrame2 f2 = new JFrame2();
              f2.setVisible(true);
              try {
                  String query = "select name from decipline";
                  pst = conn.prepareStatement(query);
                  rs = pst.executeQuery();
                  while(rs.next()) {  
                      String str = rs.getString("name");
                      JButton btn = new JButton(str);
                      System.out.println(str);
                      btn.addActionListener(this);
                      btn.setBounds(154, 112, 89, 23);
                      f2.getContentPane().add(btn);               
                  }
              } catch(Exception E) {
                  E.printStackTrace();
              } 
          }
      });
  </code></pre>