title: How to make a new set of JTextFields appear on new line after the button has been clicked once
body: <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  public class NewTextFields {
  
      public static void main(String[] args) {
  
          final int width = 1200;
          final int height = 800;
  
          JFrame frame = new JFrame("Title");
          JPanel panel = new JPanel();
          JButton btn = new JButton("ADD Field");
          JTextField[] tfield = new JTextField[10];
          GridBagConstraints gbc = new GridBagConstraints();
  
          frame.setPreferredSize(new Dimension(width, height));
          frame.setMinimumSize(new Dimension(width, height));
          frame.setMaximumSize(new Dimension(width, height));
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setLocationRelativeTo(null);
          frame.setResizable(false);
  
          panel.setSize(width, height);
          panel.setLayout(new GridBagLayout());
          frame.add(panel);
  
          gbc.insets = new Insets(1,1,1,1);
  
  
          btn.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
  
                  int i;
                  for (i = 0; i &lt; 10; i++) {
                      tfield[i] = new JTextField(5);
  
                      panel.add(tfield[i], gbc);
                      panel.revalidate();
  
                  }
  
              }
          });
  
          panel.add(btn, gbc);
  
          frame.pack();
          frame.setVisible(true);
  
      }
  
  }
  
  </code></pre>
  
  <p>Im trying to test out certain things here if anyone can help me out i wanted to make abutton which creates a new set of JTexfields in a middle of the screen while a button in somewhere on side and after the line are created (max is 6) can i use a document listener on each line. Im new and i dont know how to do all that just asking if its possible.</p>