}*/
switch(month_num){
case 0:setBG(\
case 1:setBG(\ case 2:setBG(\ case 3:setBG(\ case 4:setBG(\ case 5:setBG(\ case 6:setBG(\ case 7:setBG(\ case 8:setBG(\ case 9:setBG(\ case 10:setBG(\ case 11:setBG(\ } updateUI();
} public void actionPerformed(ActionEvent e) { if (e.getSource() == Year || e.getSource() == Month) { this.setYM();
this.setImg(month_num); this.setDay();
}
else if(e.getSource()==Up1){ this.setYM(); if(month_num==11){ int y=Integer.parseInt(year_num); y++;
this.setYM(); month_num=0;
Month.setSelectedIndex(month_num); year_num=Integer.toString(y); Year.setText(year_num);
this.setImg(month_num);
}
}
this.setDay();
else{ }
Month.setSelectedIndex(++month_num); this.setDay();
this.setImg(month_num);
else if(e.getSource()==Down1){ }
else if(e.getSource()==Down2){
this.setYM();
int y=Integer.parseInt(year_num); y--;
this.setYM();
year_num=Integer.toString(y); Year.setText(year_num); this.setDay(); this.setYM(); if(month_num==0){ } else{ }
Month.setSelectedIndex(--month_num); this.setDay();
this.setImg(month_num);
int y=Integer.parseInt(year_num); y--;
this.setYM(); month_num=11;
Month.setSelectedIndex(month_num); year_num=Integer.toString(y); Year.setText(year_num); this.setDay();
}
}
this.setImg(month_num);
else if(e.getSource()==Up2){ }
else if(e.getSource()==Today){ }
bool=true; this.setYM(); this.setDay();
Year.setText(year_num);
Month.setSelectedIndex(month_num); this.setYM();
int y=Integer.parseInt(year_num); y++;
this.setYM();
year_num=Integer.toString(y); Year.setText(year_num); this.setDay();
this.setImg(month_num);
this.setImg(month_num);
public void Button_dayyearboxActionPerformed(ActionEvent e){ strbuttonday=e.getActionCommand(); };
public int getDay(){
strbuttonyear=Year.getText(); day=Integer.parseInt(strbuttonday);
strbuttonmonth=Month.getSelectedIndex()+1+\
if(strbuttonday.length()<2){strbuttonday=\if(strbuttonmonth.length()<2){strbuttonmonth=\
//day=calendar.get(DAY_OF_MONTH); return day;}
public void paintComponent(Graphics g){
} }
super.paintComponent(g);
ImageIcon img=new ImageIcon(background); g.drawImage(img.getImage(),0,0,1150,750,this);
这里主要用来定义日历的排版布局,给日历添加监听,使其能实现日历的翻页、相关背景的变换、点击日历上相应按钮能显示时钟及备忘录等功能。
Clock.java
import java.awt.*; import javax.swing.*;
import java.applet.AudioClip; import java.io.*;
import java.applet.Applet;
import java.net.MalformedURLException; import java.net.URL; import
java.awt.event.ActionListener;
import
java.awt.event.ActionEvent;
import java.util.Calendar; import java.lang.String;
public class Clock extends JFrame { public Clock(){
DrawClock dc=new DrawClock(); add(dc,BorderLayout.CENTER); setSize(640,560); setVisible(true);
setExtendedState(JFrame.MAXIMIZED_BOTH);
//添加计时器 时间间隔为1s int delay1 = 1000;
ActionListener drawClock1 = new ActionListener(){
相关推荐: