资源简介
一个java编写基于JFrame万年历小程序
代码片段和文件信息
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.JButton;
import javax.swing.JDialog;
import javax.swing.Jframe;
import javax.swing.JLabel;
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(nullastr);
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(21));
private JPanel p5 = new JPanel(new BorderLayout());
private JButton bAdd = new JButton(“保存日志“);
private JButton bDel = new JButton(“删除日志“);
private JTextArea jta = new JTextArea(); //jta--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;
public wannianli()
{
super(“万年历“); //框架命名
this.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);//窗口关闭函数
this.getContentPane().setLayout(new BorderLayout(10 0));
jta.setLineWrap(true);
table.setGridColor(Color.GRAY); //星期之间的网格线是灰色的
table.setColumnSelectionAllowed(true);
table.setSelectionBackground(Color.BLACK);//当选定某一天时这一天背景黑色
table.setSelectionForeground(Color.GREEN);//选定的日期字体是绿色的
table.setBackground(new Color(184207229));//日期显示表格颜色浅蓝色
table.setFont(new Font(“黑体“Font.B
- 上一篇:Android DropDownMenu下拉菜单
- 下一篇:基于java的倒排索引
评论
共有 条评论