第一范文网 - 专业文章范例文档资料分享平台

java万年历设计报告

来源:用户分享 时间:2025/5/28 19:55:38 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

5

import javax.swing.*; import java.awt.*;

import java.awt.event.*;

public class Month extends Box implements ActionListener//ActionListener接口 {

int month;

JTextField showMonth=null; JButton RMonth,NMonth; CalendarPad cal;

public Month(CalendarPad c) {

super(BoxLayout.X_AXIS); this.cal=c;

showMonth=new JTextField(2); month=c.getMonth();

showMonth.setEditable(false);

showMonth.setForeground(Color.blue); showMonth.setFont(new Font(\NMonth=new JButton(\下月\RMonth=new JButton(\上月\ add(RMonth); add(showMonth); add(NMonth);

RMonth.addActionListener(this); NMonth.addActionListener(this); showMonth.setText(\ }

public void setMonth(int month) {

if(month<=12&&month>=1) {

this.month=month; } else {

this.month=1; }

showMonth.setText(\ }

public int getMonth() {

return month; }

6

public void actionPerformed(ActionEvent e) {

if(e.getSource()==RMonth) {

if(month>=2) {

month=month-1; cal.setMonth(month);

cal.setCal(cal.getYear(),month); }

else if(month==1) {

month=12;

cal.setMonth(month);

cal.setCal(cal.getYear(),month); }

showMonth.setText(\ }

else if(e.getSource()==NMonth) {

if(month<12) {

month=month+1; cal.setMonth(month);

cal.setCal(cal.getYear(),month); }

else if(month==12) {

month=1;

cal.setMonth(month);

cal.setCal(cal.getYear(),month); }

showMonth.setText(\ } } }

//对年分的选择

package javaapplication13;

import javax.swing.*; import java.awt.*;

import java.awt.event.*;

public class Year extends Box implements ActionListener//ActionListener接口

7

{

int year;

JTextField showYear=null; JButton NYear,RYear; CalendarPad cal;

public Year(CalendarPad c) {

super(BoxLayout.X_AXIS); showYear=new JTextField(4); showYear.setForeground(Color.blue); showYear.setFont(new Font(\ this.cal=c;

year=cal.getYear();

NYear=new JButton(\下年\RYear=new JButton(\上年\ add(RYear); add(showYear); add(NYear);

showYear.addActionListener(this); RYear.addActionListener(this); NYear.addActionListener(this); }

public void setYear(int year) {

this.year=year;

showYear.setText(\ }

public int getYear() {

return year; }

public void actionPerformed(ActionEvent e) {

if(e.getSource()==RYear) {

year=year-1;

showYear.setText(\ cal.setYear(year);

cal.setCal(year,cal.getMonth()); }

else if(e.getSource()==NYear) {

year=year+1;

showYear.setText(\

8

cal.setYear(year);

cal.setCal(year,cal.getMonth()); }

else if(e.getSource()==showYear) {

try {

year=Integer.parseInt(showYear.getText()); showYear.setText(\ cal.setYear(year);

cal.setCal(year,cal.getMonth()); }

catch(NumberFormatException ee) {

showYear.setText(\ cal.setYear(year);

cal.setCal(year,cal.getMonth()); } } } }

//对备忘录的操作

package javaapplication13;

import java.awt.*;

import java.awt.event.*; import java.util.*; import javax.swing.*;

import javax.swing.event.*; import java.io.*;

public class NotePad extends JPanel implements ActionListener {

JTextArea text; JButton save_log,del_log; Hashtable table; JLabel mes_label; int year,month,day; File file;

CalendarPad calendar;

public NotePad(CalendarPad calendar)//构造函数 {

this.calendar=calendar;

Calendar now = Calendar.getInstance();

搜索更多关于: java万年历设计报告 的文档
java万年历设计报告.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c2tbbc6b36y5zpal1bu62_2.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top