Java Swing: JButton creates new JTextField(s)
问题 Hello :) I am beginner in Java Swing and I can't google solution for my problem. I have a JPanel and want to add JTextField(s) dynamically after pressing a JButton. And how can I getText() from them later? My code, commented part isn't working properly. Variable 'counter' counts how many fields I have in panel. public class AppPanel extends JPanel { private JTextField tfData[]; private JButton btAdd; private int counter = 1; public AppPanel() { setLayout(null); //tfData[counter] = new