Java学习
来源:百度知道 编辑:UC知道 时间:2024/05/22 13:13:06
学习用的
在客户信息applet里添加一个功能,把当前的日期和时间显示在applet的状态栏上。写出此代码。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;
class IllegalAgeException extends Exception
{
public String getMessage()
{
return "Invalid Age. The customer should not be provided with a connection";
}
}
public class CustomerApplet extends JApplet implements Runnable
{
int custAge;
JPanel panelObject;
JButton buttonAccept;
JLabel labelCustAge;
JTextField textCustAge;
Thread datimeThread;
Date date;
GregorianCalendar calendar;
String strDate, strTime, strStatus;
void setAge(int age) throws IllegalAgeException
{
if((age<20) || (age>60))
throw new IllegalAgeException();
custAge=age;
}