java 万年历 源代码
片段如下:
package wannianli;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
//import java.sql.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
public class wannianli extends JFrame implements ActionListener, MouseListener
{
private Calendar cld = Calendar.getInstance();
private String [] astr = {"星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"};
private DefaultTableModel dtm = new DefaultTableModel(null,astr);
private JTable table = new JTable(dtm); //装日期的表格
private JScrollPane sp = new JScrollPane(table);
private JButton bLastYear = new JButton("上一年");
private JButton bNextYear = new JButton("下一年");
private JButton bLastMonth = new JButton("上月");
private JButton bNextMonth = new JButton("下月");
private JTextField jtfYear = new JTextField(5);//jtfYear年份显示和输入文本框,允许编辑单行文本
private JTextField jtfMonth = new JTextField(2);//jtfMonth月份显示文本框
private JPanel p1 = new JPanel(); //装入控制日期按钮的模块
private JPanel p2 = new JPanel();
private JPanel p3 = new JPanel(new BorderLayout());
private JPanel p4 = new JPanel(new GridLayout(2,1));
private JPanel p5 = new JPanel(new BorderLayout());
private JButton bAdd = new JButton("保存日志");
private JButton bDel = new JButton("删除日志");
private JTextArea jta = new JTextArea(); //JTextArea 是一个显示纯文本的多行区域
private JScrollPane jsp = new JScrollPane(jta); //管理视口、可选的垂直和水平滚动条以及可选的行和列标题视口
private JLabel l = new JLabel("小提示:可直接输入年份,提高查询效率!");
private JLabel lt = new JLabel();//系统时间
private JLabel ld = new JLabel();//日期是否被选择
private int lastTime;
JMenuBar jmb = new JMenuBar();
JMenu view;
1