How can i read the information from JTextField
?
private class Caverage implements ActionListener {
public void actionPerformed(ActionEvent AVR) {
int num1 =Integer.parseInt(num_ofC.getText());
JTextField[] coursg = new JTextField[num1];
c.add(CAV);
// Add JTextField if i Click the jbutton Click
if (AVR.getSource() == Click) {
for (int i =0;i<coursg.length;i++) {
coursg[i] = new JTextField("",17);
c.add(coursg[i]);
setSize(700,240);
}
// Read JTextField if i click the jbutton CAV
if (AVR.getSource() == CAV) {
for (int i =0;i<coursg.length;i++) {
int num2 =Integer.parseInt(coursg[i].getText());
System.out.println(num2);
}
}
}
}
}
Check your brackets. Your second if
is inside the first if
and AVR.getSource()
cannot be Click
and CVR
at the same time.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.