0

I have a frame with a jPanel, a button and about 50 jTextFields in it. I need to write an array one item in one jTextField on button click event. How can it be done?

Albin Shaji
  • 61
  • 1
  • 11

1 Answers1

1

Use ActionListioner and add an array item in it like this:

class MyFrame{

    private int i=0;
    private JTextField jTextField;
    private JButton jButton;
    MyFrame(){

            jButton = new JButton("Click");
            jTextField = new JTextField();
            jButton.addActionListener(new ActionListener(){

                    public void actionPerformed(ActionEvent e) {
                            jTextField.setText(arry[i]);
                            i+=1;
                    }
            });
    }

}