This is really leaving me confused. Basically im trying to create this App that will let you know when the time you set has occurred or w.e… Like an alarm clock type thing.
Here is the code, the problem is that the APPOINTMENT dialog box is not popping up when the times are equal. It does pop up when i just test it and compare Dates that i know are the same.
Here is the code
public void run() {
// lower ThreadPriority
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
// run a long while (true) this means in our case "always"
while(true)
{
appts = gui.getAppts();
date = new Date();
gui.updateDate(date);
for(int i = 0; i < appts.size(); i++)
{
Appointment a = appts.get(i);
Date ab = a.getDate();
System.out.println(ab+" "+date);
if(ab.compareTo(date) == 0)
{
JOptionPane.showConfirmDialog(null,"Appointment!");
}
}
repaint();
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
// set ThreadPriority to maximum value
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
}
}
Basically i get the Appointments ArrayList
set the date variable as the new (current) date
Update the GUI with the new date
Then i cycle through all the appointments and see if the dates compare to eachother and equal 0 if it does, then i show the DialogBox…
I even Printed out the dates to see when they are the same, and at one point they are the same, but it still does not show up…
THanks for the help in advanced.