• 大小: 184KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: Java
  • 标签: 天津大学  Java  

资源简介

1.显示当前日期 2.可以通过下拉菜单选择年(1970~2099)和月来查看当月日历 3.可以点击“今天”按钮返回今日所在月日历 4.点击修改时间选择年月日时分秒可以修改时间 5.时区默认选择北京时间 6.修改过的时间可以通过“根据本地系统时间更新”按钮更新至系统时间

资源截图

代码片段和文件信息

package WORK;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.AffineTransform;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.Jframe;
import javax.swing.JLabel;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

public class MyCalendar extends Thread implements MouseListener ActionListener {
    private Jframe f;
    private JComboBox yearCb monCbhourCbminCbsenCbsqCb;
    private JLabel l1 l2 l3 l4 l5 l6 l7 l8 l9l10l11l12aboutMitimeMij1;
    private JMenuBar mainMb;
    private JButton returnBt;
    private JButton changeoknob1;
    private JLabel[][] dayLb;
    private String title = “时间与日期“;
    private MyDrawPanel drawPanel;
    private String zone = “Asia/Beijing“;
    public Long time;
    private JTabbedPane jtp;
    /**
     * 表示年份
     */
    public static final int YEAR = 1;
    /**
     * 表示月份
     *
     * 与Java官方月份是从0开始的表示形式不同这里的月份是从1开始的。
     */
    public static final int MONTH = 2;
    /**
     * 表示某月中的某天(即年月日中的“日“)
     */
    public static final int DAY_OF_MONTH = 3;
    /**
     * 表示星期几
     */
    public static final int DAY_OF_WEEK = 9;

    public MyCalendar() {
        this.load();
    }

    /**
     * 构造方法
     *
     * @param title
     *            标题
     */
    public MyCalendar(String title) {
        this.title = title;
        this.load();
    }

    /**
     * 主流程控制方法
     */
    private void load() {
        this.instantiate();
        this.init();
        this.setUI();
        this.addAction();
        this.start();
        this.f.setVisible(true);
    }

    /**
     * 实例化所有对象的方法
     */
    private void instantiate() {
        this.f = new Jframe(title);
        this.yearCb = new JComboBox<>();
        this.monCb = new JComboBox<>();
        this.sqCb = new JComboBox<>();
        this.hourCb = new JComboBox<>();
        this.minCb = new JComboBox<>();
        this.senCb = new JComboBox<>();
        this.returnBt = new JButton(“今天“);
        this.change = new JButton(“修改时间“);
        this.ok = new JButton(“确定“);
        this.no = new JButton(“取消“);
        this.time=0L;
        this.jtp = new JTabbedPane();
        this.l1 = new JLabel(“年“);
        this.l2 = new JLabel(“月“);
        this.l3 = new JLabel(“日“);
        this.l4 = new JLabel(“一“);
        this.l5 = n

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        3570  2019-01-08 20:36  java大作业\MyCalendar$MyDrawPanel.class
     文件       12236  2019-01-08 20:36  java大作业\MyCalendar.class
     文件      185133  2019-01-08 23:47  java大作业\MyCalendar.gif
     文件       20007  2019-01-08 20:36  java大作业\MyCalendar.java

评论

共有 条评论