Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java Applets

843802Apr 13 2009 — edited Aug 26 2009
I have written a java applet for birthday reminder. The applet gets system date and reads a file containg the birthday dates. If match occurs, it displays the name of the person celebrating the birthday on the applet. The code works fine with applet viewer tool. But doesn't run in internet Explorer. Also i need to know how to convert this applet into .exe file?
The code is as follows:
import java.io.*;
import java.util.*;
import java.awt.*;
import java.applet.*;


public class Birthday extends Applet
{
int d,m,y;
Calendar cal = Calendar.getInstance();
int dat = cal.get(Calendar.DATE);
String dat1=""+dat+" -";
int month = cal.get(Calendar.MONTH) + 1;
String month1=""+month+" -";
int year=cal.get(Calendar.YEAR);
String year1=""+year+"";
String msg="";

public void init()
{
try
{
Scanner s=new Scanner(new File("remind.txt"));
while(s.hasNextLine())
{
String line=s.nextLine();
Scanner xline=new Scanner(line);
//System.out.println(line +"\n");
d=xline.nextInt();
if(d==dat)
{
m=xline.nextInt();
if (m==month)
{
msg="Hey ! Good news ! Today is "+xline.next()+" Birthday";
repaint();
//System.out.println("Hey ! Good news ! Today is "+xline.next()+" Birthday");
}
}
}
}
catch(FileNotFoundException e)
{
System.out.println("Error : "+e.getMessage());
}

}

public void paint(Graphics g)
{
Font f=new Font("Arial",Font.BOLD,20);
g.setFont(f);
g.setColor(Color.white);
setBackground(Color.red);
showStatus("Birthday reminder");

g.drawString(msg,100,200);

}
}

remind.txt(first column-date, second column-month, third column-name)
4 12 Tom
3 2 Shini
8 3 Saji
6 7 SOS
13 4 SHS
6 9 SS
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 23 2009
Added on Apr 13 2009
2 comments
205 views