Recently has been trying to fill because of ACM and delayed professional courses, O (︶^︶) o Alas, I also like C language very much.
Pity.. Can only take one step at a step.
Mycalender:
Import java.awt.*;p Ublic class Mycalcalender {public static void main (string[] args) {windowactionevent win=new windowact Ionevent (); Readlisten listener=new Readlisten ();//create monitor (listener can be arbitrary) Container con=win.getcontentpane (); Con.setbackground ( Color.green); Win.setmycommandlistener (listener);//window Combination monitor Win.settitle ("-My perpetual calendar ———"); Win.setbounds ( 100,100,610,560);}}
Windowactionevent:
Import java.awt.*;import javax.swing.*;import java.awt.event.*;p ublic class Windowactionevent extends JFrame{ JTextField TextInput; JTextArea textshow; JButton button;public windowactionevent () {init (); setvisible (true); Setdefaultcloseoperation (Jframe.exit_on_ CLOSE);} void init () {//Build window setlayout (new FlowLayout ()); Add (new JLabel ("Please enter the year you want to query (after 1900):")); textinput=new JTextField (15) Add (textInput), Button=new JButton ("OK"), add (Button), add (New JLabel (" Calendar of the Year is:"), Textshow=new JTextArea ( 25,51); Add (new JScrollPane (Textshow));} void Setmycommandlistener (Readlisten listener) {Listener.setjtextfield (textInput); Listener.setjtextarea (Textshow) ; Button.addactionlistener (listener);//button is the event source, listener is the monitor textinput.addactionlistener (listener);// TextInput is the event source, listener is the monitor}}
Readlisten:
Import Java.awt.event.*;import javax.swing. *;p Ublic class Readlisten implements Actionlistener{jtextarea Textshow; JTextField textinput;public void Setjtextarea (JTextArea area) {Textshow=area;} public void Setjtextfield (JTextField text) {Textinput=text;} public void actionperformed (ActionEvent e) {double nowyears=double.parsedouble (Textinput.gettext ());p rint (Nowyears) ;} void print (double nowyears) {int day=0,mon[]={0,31,28,31,30,31,30,31,31,30,31,30,31};for (int year=1990;year< nowyears;year++) {if (year%4==0&&year%100!=0| | year%400==0) day+=366;elseday+=365;} int week= (day+1)%7;textshow.settext ("1th month: \ nthe day \ t \ two \ t three \ Four \ five \ t six \ n"); if (nowyears%4==0&&nowyears%100!=0| | nowyears%400==0) Mon[2]=29;elsemon[2]=28;int Monday=1;while (monday<13) {int t=1;if (week==7) week=0;for (int i=0;i <week;i++) textshow.append ("\ T"), while (T<=mon[monday]) {if (week==7) {week=0;textshow.append ("\ n");} Textshow.append (t+ "\ t"); t++;week++;} Textshow.append ("\ n"); Monday++;if (monday==13) break;textshow.append ("+mond")ay+ "Month: \ n"); Textshow.append ("Day \ t \ two \ t three \ Four \ five \ t six \ n");}} This is the result of the operation:
Java Perpetual calendar