import java.io.DataInputStream.*;
import java.io.File.*;
import java.io.FileInputStream.*;
import java.io.FileOutputStream.*;
import java.util.Date.*;
import java.util.StringTokenizer.*;
import java.util.Vector.*;
import java.awt.*;
import java.awt.List.*;
import javax.swing.*;
import java.util.*;
public class AddDialog extends JDialog
{
TextField hourTF, minutesTF, dateTF;
Choice month, years;
TextField notice;
Vector theRecorders;
List theList;
AddDialog(Vector records, List aList, Frame parents)
{
super(parent, true);
setTitle("Add an Event");
theRecords = records;
theList = aList;
Panel centerP = new Panel();
centerP.setLayout(new BorderLayout());
Panel bottomP = new Panel();
bottomP.setLayout(new FlowLayout(FlowLayout.CENTER));
add("Center", centerP);
add("South", bottomP);
Panel northCenterPanel = new Panel();
northCenterPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
Panel centerCenterPanel = new Panel();
centerCenterPanel.setLayout(new BorderLayout());
centerP.add("North",northCenterPanel);
centerP.add("Center",centerCenterPanel);
bottomP.add(new Button("Add"));
bottomP.add(new Button("Clear"));
bottomP.add(new Button("Done"));
hourTF = new TextField(3);
minutesTF = new TextField(3);
dateTF = new TextField(3);
month = new Choice();
month.addItem("January ");
month.addItem("February ");
month.addItem("March ");
month.addItem("April ");
month.addItem("May ");
month.addItem("June ");
month.addItem("July ");
month.addItem("August ");
month.addItem("September ");
month.addItem("October ");
month.addItem("November ");
month.addItem("December ");
years = new Choice();
years.addItem("1995 ");
years.addItem("1996 ");
years.addItem("1997 ");
years.addItem("1998 ");
years.addItem("1999 ");
years.addItem("2000 ");
years.addItem("2001 ");
years.addItem("2002 ");
years.addItem("2003 ");
northCenterPanel.add(new Label("Event Date:"));
northCenterPanel.add(new Label("HOUR:"));
northCenterPanel.add(hourTF);
northCenterPanel.add(new Label("MIN:"));
northCenterPanel.add(minutesTF);
northCenterPanel.add(new Label("DATE:"));
northCenterPanel.add(dateTF);
northCenterPanel.add(month);
northCenterPanel.add(years);
centerCentralPanel.add("North",new Label("Event Notice"));
notice = new TextField(60);
centerCentralPanel.add("Center",notice);
move(50, 80);
pack();
show();
}
public boolean handleEvent(Event evt)
{
switch(evt.id)
{
case Event.ACTION_EVENT:
if ("Done".equals(evt.arg))
{
dispose();
return true;
}
else if ("Add".equals(evt.arg))
{
String hourStr=null, minStr=null;
String DateStr=null, yearstr=null;
hourStr = hourTF.getText();
minStr = minutesTF.getText();
dataStr = dateTF.getText();
yearStr = years.getSelectedItem();
yearStr = yearStr.trin();
int mon = mon.getSelectedIndex();
int hour, min, date, year;
try
{
hour = Integer.parseInt(hourStr);
min = Integer.parseInt(minStr);
date = Integer.parseInt(dateStr);
year = Integer.parseInt(yearStr);
year -= 1900;
}
catch (Exception e)
{
e.printStackTrace();
return true;
}
Date aDate = new Date (year, mon, date, hour, min, 0);
String msg = notice.getText();
Record aRec = new Record(aDate,msg);
theRecords.addElement(aRec);
theList.addItem(aRec.toString());
return true;
}
else if ("Clear".equals(evt.arg))
{
hourTF.setText("");
minutesTF.setText("");
dateTF.setText("");
notice.setText("");
}
break;
case Event.WINDOW_DESTROY:
dispose();
return true;
default:
return false;
}
return false;
}
}
class ReminderWindow extends Frame
{
private Vector reminders;
private int defWidth, defHeight;
private List RecordList;
private int currentCount;
private Date now;
private Date startDate;
private Date endDate;
ReminderWindow()
{
super("Memory Assistent");
reminders = new Vector(3);
RecordList = new List(12,true);
DataInputStream dis = new DataInputStream(System.in);
now = new Date();
startDate = (Date) new Date(now.getTime());
startDate.setHours(0);
startDate.setMinutes(0);
endDate = (Date) new Date(now.getTime());
endDate.setHours(23);
endDate.setMinutes(59);
File dataFile = new File("Reminder.data");
if (dataFile.exists())
{
try
{
FileInputStream fis = new FileInputStream("Reminder.data");
DataInputStream dis2 = new DataInputStream(fis);
String line = null;
while ( (line = dis2.readLine()) != null)
{
Record theRec = Record.parseRecord(line);
if (theRec != null)
{
Record theRec = Record.parseRecord(line);
if (theRec != null)
{
reminders.addElement(theRec);
Date theDate = (Date) theRec.getDate();
if (theDate.after(startDate) && theDate.before(endDate))
{
RecordList.addItem(theRec.toString());
}
}
else
{
System.out.println("Unable to get a Reminder.");
}
}
fis.close();
}
catch (Exception e)
{
System.out.println("Unable to process Reminder.dat");
e.printStackTrace();
System.exit(1);
}
}
currentCount = reminders.size();
Toolkit theToolkit = Toolkit.getDefaultToolkit();
Dimension size = theToolkit.getScreenSize();
defWidth = size.width/12 * 8;
defHeight = size.height/12 * 10;
Menubar mBar = new MenuBar();
setMenuBar(mBar);
Menu fileMenu = new Menu("File");
mBar.add(fillMenu);
Menu RecordMenu = new Menu("Record");
mBar.add(RecordMenu);
fileMenu.add(new MenuItem("Exit"));
RecordMenu.add(new MenuItem("Add"));
RecordMenu.add(new MenuItem("Delete"));
RecordMenu.add(new MenuItem("Today"));
RecordMenu.add(new MenuItem("All"));
Panel centerP = new Panel();
centerP.setLayout(new BorderLayout());
Panel bottomP = new Panel();
bottomP.setLayout(new FlowLayout(FlowLayout.LEFT));
add("Center",centerP);
add("South",bottomP);
centerP.add("Center",RecordList);
bottomP.add(new Label("Now: " + now.toLocaleString() + " "));
bottomP.add(new Button("Today"));
bottomP.add(new Button("All"));
bottomP.add(new Button("Add"));
bottomP.add(new Button("Delete"));
bottomP.add(new Button("Exit"));
move(size.width/12, size.height/20);
resize(defWidth, defHeight);
show();
}
public boolean handleEvent(Event evt)
{
switch (evt.id)
{
case Event.ACTION_EVENT:
if ("Exit".equals(evt.arg))
{
dispose()
try
{
FileOutputStream fos = new FileOutputStream("Reminder.data");
PrintStream ps = new PrintStream(fos);
for (int i=0; i < reminders.size(); i++)
ps.println(((Record)reminders.elementAt(i)).toString());
fos.Close();
}
catch (Exception e)
{
System.out.println("10 error on reminder.data");
System.exit(1);
}
System.exit(0);
}
else if ("Add".equals(evt.arg))
{
new AddDialog(reminders, RecordList, this);
}
else if ("Delete".equals(evt.arg))
{
String item[] = RecordList.getSelectedItem();
for (int i=0; i < items.length; i++)
{
Record theRecord = Record.parseRecord
(items);
for (int j=0; j < reminders.size(); j++)
{
if (((theRecord.getDate()).equals(((Record) reminders.elementsAt
}
}
}
}
}
}
}
import java.io.File.*;
import java.io.FileInputStream.*;
import java.io.FileOutputStream.*;
import java.util.Date.*;
import java.util.StringTokenizer.*;
import java.util.Vector.*;
import java.awt.*;
import java.awt.List.*;
import javax.swing.*;
import java.util.*;
public class AddDialog extends JDialog
{
TextField hourTF, minutesTF, dateTF;
Choice month, years;
TextField notice;
Vector theRecorders;
List theList;
AddDialog(Vector records, List aList, Frame parents)
{
super(parent, true);
setTitle("Add an Event");
theRecords = records;
theList = aList;
Panel centerP = new Panel();
centerP.setLayout(new BorderLayout());
Panel bottomP = new Panel();
bottomP.setLayout(new FlowLayout(FlowLayout.CENTER));
add("Center", centerP);
add("South", bottomP);
Panel northCenterPanel = new Panel();
northCenterPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
Panel centerCenterPanel = new Panel();
centerCenterPanel.setLayout(new BorderLayout());
centerP.add("North",northCenterPanel);
centerP.add("Center",centerCenterPanel);
bottomP.add(new Button("Add"));
bottomP.add(new Button("Clear"));
bottomP.add(new Button("Done"));
hourTF = new TextField(3);
minutesTF = new TextField(3);
dateTF = new TextField(3);
month = new Choice();
month.addItem("January ");
month.addItem("February ");
month.addItem("March ");
month.addItem("April ");
month.addItem("May ");
month.addItem("June ");
month.addItem("July ");
month.addItem("August ");
month.addItem("September ");
month.addItem("October ");
month.addItem("November ");
month.addItem("December ");
years = new Choice();
years.addItem("1995 ");
years.addItem("1996 ");
years.addItem("1997 ");
years.addItem("1998 ");
years.addItem("1999 ");
years.addItem("2000 ");
years.addItem("2001 ");
years.addItem("2002 ");
years.addItem("2003 ");
northCenterPanel.add(new Label("Event Date:"));
northCenterPanel.add(new Label("HOUR:"));
northCenterPanel.add(hourTF);
northCenterPanel.add(new Label("MIN:"));
northCenterPanel.add(minutesTF);
northCenterPanel.add(new Label("DATE:"));
northCenterPanel.add(dateTF);
northCenterPanel.add(month);
northCenterPanel.add(years);
centerCentralPanel.add("North",new Label("Event Notice"));
notice = new TextField(60);
centerCentralPanel.add("Center",notice);
move(50, 80);
pack();
show();
}
public boolean handleEvent(Event evt)
{
switch(evt.id)
{
case Event.ACTION_EVENT:
if ("Done".equals(evt.arg))
{
dispose();
return true;
}
else if ("Add".equals(evt.arg))
{
String hourStr=null, minStr=null;
String DateStr=null, yearstr=null;
hourStr = hourTF.getText();
minStr = minutesTF.getText();
dataStr = dateTF.getText();
yearStr = years.getSelectedItem();
yearStr = yearStr.trin();
int mon = mon.getSelectedIndex();
int hour, min, date, year;
try
{
hour = Integer.parseInt(hourStr);
min = Integer.parseInt(minStr);
date = Integer.parseInt(dateStr);
year = Integer.parseInt(yearStr);
year -= 1900;
}
catch (Exception e)
{
e.printStackTrace();
return true;
}
Date aDate = new Date (year, mon, date, hour, min, 0);
String msg = notice.getText();
Record aRec = new Record(aDate,msg);
theRecords.addElement(aRec);
theList.addItem(aRec.toString());
return true;
}
else if ("Clear".equals(evt.arg))
{
hourTF.setText("");
minutesTF.setText("");
dateTF.setText("");
notice.setText("");
}
break;
case Event.WINDOW_DESTROY:
dispose();
return true;
default:
return false;
}
return false;
}
}
class ReminderWindow extends Frame
{
private Vector reminders;
private int defWidth, defHeight;
private List RecordList;
private int currentCount;
private Date now;
private Date startDate;
private Date endDate;
ReminderWindow()
{
super("Memory Assistent");
reminders = new Vector(3);
RecordList = new List(12,true);
DataInputStream dis = new DataInputStream(System.in);
now = new Date();
startDate = (Date) new Date(now.getTime());
startDate.setHours(0);
startDate.setMinutes(0);
endDate = (Date) new Date(now.getTime());
endDate.setHours(23);
endDate.setMinutes(59);
File dataFile = new File("Reminder.data");
if (dataFile.exists())
{
try
{
FileInputStream fis = new FileInputStream("Reminder.data");
DataInputStream dis2 = new DataInputStream(fis);
String line = null;
while ( (line = dis2.readLine()) != null)
{
Record theRec = Record.parseRecord(line);
if (theRec != null)
{
Record theRec = Record.parseRecord(line);
if (theRec != null)
{
reminders.addElement(theRec);
Date theDate = (Date) theRec.getDate();
if (theDate.after(startDate) && theDate.before(endDate))
{
RecordList.addItem(theRec.toString());
}
}
else
{
System.out.println("Unable to get a Reminder.");
}
}
fis.close();
}
catch (Exception e)
{
System.out.println("Unable to process Reminder.dat");
e.printStackTrace();
System.exit(1);
}
}
currentCount = reminders.size();
Toolkit theToolkit = Toolkit.getDefaultToolkit();
Dimension size = theToolkit.getScreenSize();
defWidth = size.width/12 * 8;
defHeight = size.height/12 * 10;
Menubar mBar = new MenuBar();
setMenuBar(mBar);
Menu fileMenu = new Menu("File");
mBar.add(fillMenu);
Menu RecordMenu = new Menu("Record");
mBar.add(RecordMenu);
fileMenu.add(new MenuItem("Exit"));
RecordMenu.add(new MenuItem("Add"));
RecordMenu.add(new MenuItem("Delete"));
RecordMenu.add(new MenuItem("Today"));
RecordMenu.add(new MenuItem("All"));
Panel centerP = new Panel();
centerP.setLayout(new BorderLayout());
Panel bottomP = new Panel();
bottomP.setLayout(new FlowLayout(FlowLayout.LEFT));
add("Center",centerP);
add("South",bottomP);
centerP.add("Center",RecordList);
bottomP.add(new Label("Now: " + now.toLocaleString() + " "));
bottomP.add(new Button("Today"));
bottomP.add(new Button("All"));
bottomP.add(new Button("Add"));
bottomP.add(new Button("Delete"));
bottomP.add(new Button("Exit"));
move(size.width/12, size.height/20);
resize(defWidth, defHeight);
show();
}
public boolean handleEvent(Event evt)
{
switch (evt.id)
{
case Event.ACTION_EVENT:
if ("Exit".equals(evt.arg))
{
dispose()
try
{
FileOutputStream fos = new FileOutputStream("Reminder.data");
PrintStream ps = new PrintStream(fos);
for (int i=0; i < reminders.size(); i++)
ps.println(((Record)reminders.elementAt(i)).toString());
fos.Close();
}
catch (Exception e)
{
System.out.println("10 error on reminder.data");
System.exit(1);
}
System.exit(0);
}
else if ("Add".equals(evt.arg))
{
new AddDialog(reminders, RecordList, this);
}
else if ("Delete".equals(evt.arg))
{
String item[] = RecordList.getSelectedItem();
for (int i=0; i < items.length; i++)
{
Record theRecord = Record.parseRecord
(items);
for (int j=0; j < reminders.size(); j++)
{
if (((theRecord.getDate()).equals(((Record) reminders.elementsAt
}
}
}
}
}
}
}