I have a button and a timer in a gui program. I want the timer to trigger events and the button to trigger different events.
The button works fine but I am having trouble adding the timer event to the action listener.
Here is the code I am trying in the Action Listener. I am expecting the code in the catch to run when the timer trigers. I am using a try catch handler because the e.getActionCommand needs an action command from the timer and I do not know what it is, it appears to be "null".
The Timer does trigger the catch and so I know that the Action Performed code is trying to run for the timer.
public void actionPerformed(ActionEvent e) {
try{
System.out.println("e is " + e);
if (e.getActionCommand().equals("Exit")) {
this.myExit();
}
}
catch(Exception excp) {
j.restart();
// j is my Timer
System.out.println(excp + "excp " + e);
}
}
Where am I going wrong?