posted 19 years ago
I had a frame with question and answer textfields. Timer gets executed for every 30 seconds and a new frame will be displayed. But when the user enters an answer the timer should stop. How to acheive this?
I tried by using getSource() method like
public class TimerListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
Object source = event.getSource();
if(source instanceOf JTextField) {
timer.stop();
}
}
}
But its not working. Here the source is coming as timer source but not as textfield source. So how to get the source of a textfield in the timerlisterner class?