java万年历设计报告

2026/1/21 3:21:58

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万年历设计报告.doc 将本文的Word文档下载到电脑
搜索更多关于: java万年历设计报告 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219