java写万年历的代码Word 文档 (2)

上传人:汽*** 文档编号:408870719 上传时间:2023-09-23 格式:DOC 页数:14 大小:34.50KB
返回 下载 相关 举报
java写万年历的代码Word 文档 (2)_第1页
第1页 / 共14页
java写万年历的代码Word 文档 (2)_第2页
第2页 / 共14页
java写万年历的代码Word 文档 (2)_第3页
第3页 / 共14页
java写万年历的代码Word 文档 (2)_第4页
第4页 / 共14页
java写万年历的代码Word 文档 (2)_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《java写万年历的代码Word 文档 (2)》由会员分享,可在线阅读,更多相关《java写万年历的代码Word 文档 (2)(14页珍藏版)》请在金锄头文库上搜索。

1、import java.awt.Color; import java.awt.Font; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.Date; import java.util.GregorianCalendar; import javax.swing.JButton

2、; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; public class Calender2 extends JFrame implements ActionListener, ItemListener /* * 实现简朴旳日历功能 * * author Jadie version 1.0 /12/29 * */ private static final long serialVersionUID = 1L; public static void main(String

3、args) try Calender2 frame = new Calender2(); frame.setVisible(true); catch (Exception e) e.printStackTrace(); private Date date = new Date(); private GregorianCalendar gregorianCalendar = new GregorianCalendar(); private String stringWeek = new String SUN, MON, TUE, WED, THU, FRI, SAT ; private Stri

4、ng stringWeekCn = new String 星期天, 星期一, 星期二, 星期三, 星期四, 星期五, 星期六 ; private String stringMonth = new String Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sept, Oct, Nov, Dec ; private String strSysTime = new String6; / 存储目前日期信息 private String strSysNowTime = new String6; / 存储运营时日期信息 private JButton buttonDay

5、 = new JButton42; private JButton buttonWeek = new JButton7; private JLabel labelMonth = new JLabel(); private JButton buttonToday = new JButton(); private JButton buttonLastMonth = new JButton(); private JButton buttonNextMonth = new JButton(); private JComboBox comboYear = new JComboBox(); private

6、 JComboBox comboMonth = new JComboBox(); public Calender2() super(万年历-156制作); getContentPane().setLayout(new GridLayout(8, 7, 3, 5); setBounds(250, 200, 530, 360); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); comboYear.setForeground(new Color(0, 0, 255); comboYear.setFont(new Font(, Font.PLAIN, 1

7、4); for (int y = 1900; y 2101; y+) comboYear.addItem( + new Integer(y).toString(); getContentPane().add(comboYear); comboYear.addItemListener(this); final JLabel labelYear = new JLabel(); labelYear.setForeground(Color.BLUE); labelYear.setFont(new Font(新宋体, Font.PLAIN, 14); getContentPane().add(label

8、Year); labelYear.setText( 年); comboMonth.setForeground(new Color(0, 0, 255); comboMonth.setFont(new Font(, Font.PLAIN, 14); for (int m = 1; m 13; m+) comboMonth.addItem( + new Integer(m).toString(); getContentPane().add(comboMonth); comboMonth.addItemListener(this); getContentPane().add(labelMonth);

9、 labelMonth.setForeground(Color.BLUE); labelMonth.setFont(new Font(新宋体, Font.PLAIN, 14); labelMonth.setText( 月); getContentPane().add(buttonLastMonth); buttonLastMonth.setForeground(Color.BLUE); buttonLastMonth.setFont(new Font(新宋体, Font.PLAIN, 14); buttonLastMonth.setText(上月); buttonLastMonth.addAc

10、tionListener(this); getContentPane().add(buttonToday); buttonToday.setForeground(Color.BLUE); buttonToday.setFont(new Font(新宋体, Font.PLAIN, 14); buttonToday.setText(今天); buttonToday.addActionListener(this); getContentPane().add(buttonNextMonth); buttonNextMonth.setForeground(Color.BLUE); buttonNextM

11、onth.setFont(new Font(新宋体, Font.PLAIN, 14); buttonNextMonth.setText(下月); buttonNextMonth.addActionListener(this); for (int i = 0; i 7; i+) buttonWeeki = new JButton(); if (i = 0 | i = 6) buttonWeeki.setForeground(Color.RED); else buttonWeeki.setForeground(Color.BLUE); buttonWeeki.setFont(new Font(新宋

12、体, Font.PLAIN, 12); buttonWeeki.setText(stringWeekCni); getContentPane().add(buttonWeeki); for (int i = 0; i 42; i+) buttonDayi = new JButton(); buttonDayi.setText(); getContentPane().add(buttonDayi); this.setResizable(false); getSysNowTimeInfo(); setNowDate(); setNowDate(); public void setSysDate(i

13、nt year, int month) / 将日期设立为year年month月1日 gregorianCalendar.set(year, month, 1); public void actionPerformed(ActionEvent ae) if (ae.getSource() = buttonToday) setNowDate(); setNowDate(); else if (ae.getSource() = buttonLastMonth) setDate(-1); else setDate(1); public void itemStateChanged(ItemEvent arg0) setDate(0); public void getSysNowTimeInfo() / 得到程序运营时旳时间信息并存储在字符串数组strSysNowTime中 date = gregorianCalenda

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号