FileDocCategorySizeDatePackage
CalApplet.javaAPI DocExample1362Sun Mar 07 19:38:16 GMT 2004None

CalApplet

public class CalApplet extends Applet implements ActionListener
An Applet to display a "Cal" calendar component

Fields Summary
int
yy
int
mm
int
dd
Cal
cal
Panel
p
TextField
yyText
TextField
mmText
TextField
ddText
Constructors Summary
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)

		System.out.println("CalApplet::ActionPerformed");
		yy = Integer.parseInt(yyText.getText());
		mm = Integer.parseInt(mmText.getText());
		dd = Integer.parseInt(ddText.getText());

		cal.setDate(yy, mm-1, dd);
	
public voidinit()

		setLayout(new BorderLayout());

		Calendar d = new GregorianCalendar();
		yy = d.get(Calendar.YEAR);
		mm = d.get(Calendar.MONTH);
		dd = d.get(Calendar.DAY_OF_MONTH);

		add(cal    = new Cal(yy, mm, dd), BorderLayout.NORTH);
		p = new Panel();
		p.setLayout(new FlowLayout());

		// The action for changing yy or mm draws a new calendar
		p.add(yyText = new TextField(""+yy));
		yyText.addActionListener(this);
		p.add(mmText = new TextField(""+(mm+1)));
		mmText.addActionListener(this);

		// The action for changing the day just highlights that day.
		p.add(ddText = new TextField(""+dd));
		ddText.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				cal.setDayActive(Integer.parseInt(ddText.getText()));
			}
		});
		add(p, BorderLayout.SOUTH);