ReminderServicepublic class ReminderService extends Object Read a file of reminders, run each when due using java.util.Timer |
Fields Summary |
---|
Timer | timerThe Timer object |
Methods Summary |
---|
protected void | load()
BufferedReader is = new BufferedReader(
new FileReader("ReminderService.txt"));
SimpleDateFormat formatter =
new SimpleDateFormat ("yyyy MM dd hh mm");
String aLine;
while ((aLine = is.readLine()) != null) {
ParsePosition pp = new ParsePosition(0);
Date date = formatter.parse(aLine, pp);
if (date == null) {
message("Invalid date in " + aLine);
continue;
}
String mesg = aLine.substring(pp.getIndex());
timer.schedule(new Item(mesg), date);
}
| public static void | main(java.lang.String[] argv)
new ReminderService().load();
| void | message(java.lang.String message)Display a message on the console and in the GUI.
Used both by Item tasks and by mainline parser.
System.out.println("\007" + message);
JOptionPane.showMessageDialog(null,
message,
"Timer Alert", // titlebar
JOptionPane.INFORMATION_MESSAGE); // icon
|
|