I have a class that implements Actionlistener
. Upon clicking the button from this class I want it do something at a precise time I specified, earlier, and elsewhere. So I have made these classes :
class DoSomething implements ActionListener{
public void actionPerformed(ActionEvent a){
while(true){
String test = obtainTime.time;
if(test.matches("(.*)17:29:30(.*)")){
Class.doSomethingMethod();
}
//Rest of the code
}
}
}
class ObtainTime{
static DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
static Calendar cal = Calendar.getInstance();
static String time = dateFormat.format(cal.getTime());
}
So the problem is, I only get the time from when I clicked it. The second thing is the button becomes unclickable since it is still running, is there a way to make it clickable again while the code still runs in the background? Thank you for any help.