用Java applet编写的日历
时间:2011-01-07
package calendar;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
public class CalendarV2 extends Applet {
private boolean isStandalone = false;
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public CalendarV2() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
jLabel1.setText("Please Enter Year");
jLabel1.setBounds(new Rectangle(8, 30, 114, 26));
this.setLayout(null);
jTextField1.setText("");
jTextField1.setBounds(new Rectangle(129, 30, 136, 27));
jLabel2.setText("Please Ente Month");
jLabel2.setBounds(new Rectangle(4, 70, 104, 26));
jTextField2.setText("");
jTextField2.setBounds(new Rectangle(130, 69, 136, 26));
jButton1.setBounds(new Rectangle(16, 122, 233, 21));
jButton1.setText("CheckCalendarV2");
jButton1.addActionListener(new CalendarV2_jButton1_actionAdapter(this));
jButton2.setBounds(new Rectangle(16, 156, 232, 20));
jButton2.setText("Exit");
jButton2.addActionListener(new CalendarV2_jButton2_actionAdapter(this));
this.add(jButton1, null);
this.add(jTextField1, null);
this.add(jTextField2, null);
this.add(jLabel2, null);
this.add(jLabel1, null);
this.add(jButton2, null);
}
JLabel jLabel1 = new JLabel();
JTextField jTextField1 = new JTextField();
JLabel jLabel2 = new JLabel();
JTextField jTextField2 = new JTextField();
JButton jButton1 = new JButton();
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
//Main method
public static void main(String[] args) {
CalendarV2 applet = new CalendarV2();
applet.isStandalone = true;
Frame frame;
frame = new Frame();
frame.setTitle("Applet Frame");
frame.add(applet, BorderLayout.CENTER);
applet.init();
applet.start();
frame.setSize(400,320);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
frame.setVisible(true);
}
// Declare dataMember
//********************
boolean isLeapYear,isEverPressBtn=false;
int thisYear,EnterYear,EnterMonth;
//***********************************************************************************
//Methods
//***********************************************************************************
//-----计算该年天数---------------
public int checkYear(int Year){
if(Year%4==0&&Year%100!=0){
thisYear = 366;
}
if(Year%100==0&&Year%400==0){
thisYear = 366;
}
else if(Year%4!=0){
thisYear=365;
}
return thisYear;
}
//--------------------------------
//------查看是否闰年----------------
public boolean
|