Develop a java calendar that has the following... should be GUI - A calendar wit
ID: 3635477 • Letter: D
Question
Develop a java calendar that has the following... should be GUI- A calendar with 12 months
- It should say today's date.
- Set a reminder, when I click a button it should allow me to write
the information and set the time to remind if i choice or not. And
when the time arrival, a screen should pops out and remind the user
the time for the appointment is almost come.
Explanation / Answer
MIGHT HELP YOU ReminderService.java import java.io.*; import java.text.*; import java.util.*; import javax.swing.*; /** * Read a file of reminders, sleep until each is due, beep. */ public class ReminderService { class Item { Date due; String message; Item(Date d, String m) { due = d; message = m; } } ArrayList l = new ArrayList( ); public static void main(String argv[]) throws IOException { ReminderService rs = new ReminderService( ); rs.load( ); rs.run( ); } protected void load( ) throws IOException { 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( )); l.add(new Item(date, mesg)); } } public void run( ) { System.out.println("ReminderService: Starting at " + new Date( )); while (!l.isEmpty( )) { Date d = new Date( ); Item i = (Item)l.get(0); long interval = i.due.getTime() - d.getTime( ); if (interval > 0) { System.out.println("Sleeping until " + i.due); try { Thread.sleep(interval); } catch (InterruptedException e) { System.exit(1); // unexpected intr } message(i.due + ": " + i.message);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.