package calendar;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.*;
import java.awt.Font;
import javax.swing.BorderFactory;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.awt.GridLayout;
import java.awt.Color;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class DateFrame extends JFrame {
JPanel contentPane;
JButton jButton1 = new JButton();
JTextField textYear = new JTextField();
JButton jButton2 = new JButton();
JTextField textMonth = new JTextField();
JLabel jLabel1 = new JLabel();
JScrollPane jScrollPane1 = new JScrollPane();
JButton jButton3 = new JButton();
JTextArea textrizhi = new JTextArea();
JPanel jPanel1 = new JPanel();
Calendar date=Calendar.getInstance();
int week;
GridLayout gridLayout1 = new GridLayout(7,7);
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JLabel jLabel8 = new JLabel();
JLabel jLabel9 = new JLabel();
JLabel jLabel10 = new JLabel();
JLabel jLabel11 = new JLabel();
JLabel jLabel12 = new JLabel();
JLabel jLabel13 = new JLabel();
JLabel jLabel14 = new JLabel();
JLabel jLabel15 = new JLabel();
JLabel jLabel16 = new JLabel();
JLabel jLabel17 = new JLabel();
JLabel jLabel18 = new JLabel();
JLabel jLabel19 = new JLabel();
JLabel jLabel20 = new JLabel();
JLabel jLabel21 = new JLabel();
JLabel jLabel22 = new JLabel();
JLabel jLabel23 = new JLabel();
JLabel jLabel24 = new JLabel();
JLabel jLabel25 = new JLabel();
JLabel jLabel26 = new JLabel();
JLabel jLabel27 = new JLabel();
JLabel jLabel28 = new JLabel();
JLabel jLabel29 = new JLabel();
JLabel jLabel30 = new JLabel();
JLabel jLabel31 = new JLabel();
JLabel jLabel32 = new JLabel();
JLabel jLabel33 = new JLabel();
JLabel jLabel34 = new JLabel();
JLabel jLabel35 = new JLabel();
JLabel jLabel36 = new JLabel();
JLabel jLabel37 = new JLabel();
JLabel jLabel38 = new JLabel();
JLabel jLabel39 = new JLabel();
JLabel jLabel40 = new JLabel();
JLabel jLabel41 = new JLabel();
JLabel jLabel42 = new JLabel();
JLabel jLabel43 = new JLabel();
JLabel jLabel44 = new JLabel();
JLabel jLabel45 = new JLabel();
JLabel jLabel46 = new JLabel();
JLabel jLabel47 = new JLabel();
JLabel jLabel48 = new JLabel();
JLabel jLabel49 = new JLabel();
JLabel jLabel50 = new JLabel();
JLabel []day={jLabel9,jLabel10,jLabel11,jLabel12,jLabel13,jLabel14,jLabel15,jLabel16,
jLabel17,jLabel18,jLabel19,jLabel20,
jLabel21,jLabel22,jLabel23,jLabel24,jLabel25,jLabel26,
jLabel27,jLabel28,jLabel29,jLabel30,jLabel31,jLabel32,
jLabel33,jLabel34,jLabel35,jLabel36,jLabel37,jLabel38,
jLabel39,jLabel40,jLabel41,jLabel42,jLabel43,
jLabel45,jLabel46,jLabel47,jLabel48,jLabel49,jLabel50};
JButton jButton4 = new JButton();
JButton jButton5 = new JButton();
public DateFrame() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
public void display(int year,int month)//显示日历
{
int tempday=0;
GregorianCalendar gr=new GregorianCalendar(year,month-1,1);
week = gr.get(Calendar.DAY_OF_WEEK);
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
{
tempday=31;
}
else if(month==4||month==6||month==9||month==11)
{
tempday=30;
}
else if(month==2)
{
if(year%400==0)
{
tempday=28;
}else{
tempday=29;
}
}
for(int i=week, j=1;j<=tempday;i++,j++)
{
day[i].setHorizontalAlignment(SwingConstants.CENTER);
day[i].setText(String.valueOf(j));
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(null);
setSize(new Dimension(569, 390));
setTitle("日历");
jButton1.setBounds(new Rectangle(1, 22, 83, 25));
jButton1.setText("上一年");
jButton1.addActionListener(new DateFrame_jButton1_actionAdapter(this));
textYear.setEnabled(false);
textYear.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
textYear.setHorizontalAlignment(SwingConstants.CENTER);
textYear.setBounds(new Rectangle(92, 21, 79, 25));
jButton2.setBounds(new Rectangle(183, 23, 83, 25));
jButton2.setText("下一年");
jButton2.addActionListener(new DateFrame_jButton2_actionAdapter(this));
textMonth.setEnabled(false);
textMonth.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
textMonth.setHorizontalAlignment(SwingConstants.CENTER);
textMonth.setBounds(new Rectangle(359, 23, 80, 25));
textMonth.addActionListener(new DateFrame_textMonth_actionAdapter(this));
jLabel1.setFont(new java.awt.Font("黑体", Font.PLAIN, 20));
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setText("日志");
jLabel1.setBounds(new Rectangle(401, 47, 90, 38));
jScrollPane1.setBounds(new Rectangle(317, 76, 240, 238));
jButton3.setBounds(new Rectangle(419, 322, 83, 25));
jButton3.setText("保存日志");
jButton3.addActionListener(new DateFrame_jButton3_actionAdapter(this));
jPanel1.setBorder(BorderFactory.createEtchedBorder());
jPanel1.setBounds(new Rectangle(13, 76, 293, 263));
jPanel1.setLayout(gridLayout1);
jLabel2.setForeground(Color.red);
jLabel2.setBorder(null);
jLabel2.setText("星期日");
jLabel3.setText("星期一");
jLabel4.setText("星期二");
jLabel5.setText("星期三");
jLabel6.setText("星期五");
jLabel7.setForeground(Color.red);
jLabel7.setText("星期六");
jLabel8.setText("星期四");
textrizhi.setText("请写你的日志");
jLabel16.setForeground(Color.red);
jLabel23.setForeground(Color.red);
jLabel30.setForeground(Color.red);
jLabel37.setForeground(Color.red);
jLabel45.setForeground(Color.red);
jLabel50.setForeground(Color.red);
jLabel10.setForeground(Color.red);
jLabel17.setForeground(Color.red);
jLabel24.setForeground(Color.red);
jLabel31.setForeground(Color.red);
jLabel38.setForeground(Color.red);
jLabel46.setForeground(Color.red);
jButton4.setBounds(new Rectangle(270, 23, 83, 25));
jButton4.setText("上一月");
jButton4.addActionListener(new DateFrame_jButton4_actionAdapter(this));
jButton5.setBounds(new Rectangle(455, 23, 83, 25));
jButton5.setText("下一月");
jButton5.addActionListener(new DateFrame_jButton5_actionAdapter(this));
contentPane.add(jScrollPane1);
jScrollPane1.getViewport().add(textrizhi);
contentPane.add(jButton3);
contentPane.add(jLabel1);
contentPane.add(jPanel1);
jPanel1.add(jLabel2);
jPanel1.add(jLabel3);
j