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?
Asked
Active
Viewed 24 times
1 Answers
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;
}
});
}
}

Aswad Sohail
- 34
- 7