首页 > 后端开发 > 正文

急需日历记事本JAVA源代码 用java图形用户界面实现: 编写一个日历程序,能实现显示日历等简单功能。

2024-04-02 22:31:00 | 我爱编程网

今天我爱编程网小编为大家带来了急需日历记事本JAVA源代码 用java图形用户界面实现: 编写一个日历程序,能实现显示日历等简单功能。,希望能帮助到大家,一起来看看吧!

本文目录一览:

急需日历记事本JAVA源代码 用java图形用户界面实现: 编写一个日历程序,能实现显示日历等简单功能。

急需日历记事本JAVA源代码

import java.util.Calendar;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import java.util.Hashtable;

public class CalendarPad extends JFrame implements MouseListener

{

int year,month,day;

Hashtable hashtable;

File file;

JTextField showDay[];

JLabel title[];

Calendar 日历;

int 星期几;

NotePad notepad=null;

Month 负责改变月;

Year 负责改变年;

String 星期[]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};

JPanel leftPanel,rightPanel;

public CalendarPad(int year,int month,int day)

{

leftPanel=new JPanel();

JPanel leftCenter=new JPanel();

JPanel leftNorth=new JPanel();

leftCenter.setLayout(new GridLayout(7,7));

rightPanel=new JPanel();

this.year=year;

this.month=month;

this.day=day;

负责改变年=new Year(this);

负责改变年.setYear(year);

负责改变月=new Month(this);

负责改变月.setMonth(month);

title=new JLabel[7];

showDay=new JTextField[42];

for(int j=0;j<7;j++)

{

title[j]=new JLabel();

title[j].setText(星期[j]);

title[j].setBorder(BorderFactory.createRaisedBevelBorder());

leftCenter.add(title[j]);

}

title[0].setForeground(Color.red);

title[6].setForeground(Color.blue);

for(int i=0;i<42;i++)

{

showDay[i]=new JTextField();

showDay[i].addMouseListener(this);

showDay[i].setEditable(false);

leftCenter.add(showDay[i]);

}

日历=Calendar.getInstance();

Box box=Box.createHorizontalBox();

box.add(负责改变年);

box.add(负责改变月);

leftNorth.add(box);

leftPanel.setLayout(new BorderLayout());

leftPanel.add(leftNorth,BorderLayout.NORTH);

leftPanel.add(leftCenter,BorderLayout.CENTER);

leftPanel.add(new Label("请在年份输入框输入所查年份(负数表示公元前),并回车确定"),

BorderLayout.SOUTH) ;

leftPanel.validate();

Container con=getContentPane();

JSplitPane split=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,

leftPanel,rightPanel);

con.add(split,BorderLayout.CENTER);

con.validate();

hashtable=new Hashtable();

file=new File("日历记事本.txt");

if(!file.exists())

{

try{

FileOutputStream out=new FileOutputStream(file);

ObjectOutputStream objectOut=new ObjectOutputStream(out);

objectOut.writeObject(hashtable);

objectOut.close();

out.close();

}

catch(IOException e)

{

}

}

notepad=new NotePad(this);

rightPanel.add(notepad);

设置日历牌(year,month);

addWindowListener(new WindowAdapter()

{ public void windowClosing(WindowEvent e)

{

System.exit(0);

}

});

setVisible(true);

setBounds(100,50,524,285);

validate();

}

public void 设置日历牌(int year,int month)

{

日历.set(year,month-1,1);

星期几=日历.get(Calendar.DAY_OF_WEEK)-1;

if(month==1||month==2||month==3||month==5||month==7

||month==8||month==10||month==12)

{

排列号码(星期几,31);

}

else if(month==4||month==6||month==9||month==11)

{

排列号码(星期几,30);

}

else if(month==2)

{

if((year%4==0&&year%100!=0)||(year%400==0))

{

排列号码(星期几,29);

}

else

{

排列号码(星期几,28);

}

}

}

public void 排列号码(int 星期几,int 月天数)

{

for(int i=星期几,n=1;i<星期几+月天数;i++)

{

showDay[i].setText(""+n);

if(n==day)

{

showDay[i].setForeground(Color.green);

showDay[i].setFont(new Font("TimesRoman",Font.BOLD,20));

}

else

{

showDay[i].setFont(new Font("TimesRoman",Font.BOLD,12));

showDay[i].setForeground(Color.black);

}

if(i%7==6)

{

showDay[i].setForeground(Color.blue);

}

if(i%7==0)

{

showDay[i].setForeground(Color.red);

}

n++;

}

for(int i=0;i<星期几;i++)

{

showDay[i].setText("");

}

for(int i=星期几+月天数;i<42;i++)

{

showDay[i].setText("");

}

}

public int getYear()

{

return year;

}

public void setYear(int y)

{

year=y;

notepad.setYear(year);

}

public int getMonth()

{

return month;

}

public void setMonth(int m)

{

month=m;

notepad.setMonth(month);

}

public int getDay()

{

return day;

}

public void setDay(int d)

{

day=d;

notepad.setDay(day);

}

public Hashtable getHashtable()

{

return hashtable;

}

public File getFile()

{

return file;

}

public void mousePressed(MouseEvent e)

{

JTextField source=(JTextField)e.getSource();

try{

day=Integer.parseInt(source.getText());

notepad.setDay(day);

notepad.设置信息条(year,month,day);

notepad.设置文本区(null);

notepad.获取日志内容(year,month,day);

}

catch(Exception ee)

{

}

}

public void mouseClicked(MouseEvent e)

{

}

public void mouseReleased(MouseEvent e)

{

}

public void mouseEntered(MouseEvent e)

{

}

public void mouseExited(MouseEvent e)

{

}

public static void main(String args[])

{

Calendar calendar=Calendar.getInstance();

int y=calendar.get(Calendar.YEAR);

int m=calendar.get(Calendar.MONTH)+1;

int d=calendar.get(Calendar.DAY_OF_MONTH);

new CalendarPad(y,m,d);

}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class Month extends Box implements ActionListener

{

int month;

JTextField showMonth=null;

JButton 下月,上月;

CalendarPad 日历;

public Month(CalendarPad 日历)

{

super(BoxLayout.X_AXIS);

this.日历=日历;

showMonth=new JTextField(2);

month=日历.getMonth();

showMonth.setEditable(false);

showMonth.setForeground(Color.blue);

showMonth.setFont(new Font("TimesRomn",Font.BOLD,16));

下月=new JButton("下月");

上月=new JButton("上月");

add(上月);

add(showMonth);

add(下月);

上月.addActionListener(this);

下月.addActionListener(this);

showMonth.setText(""+month);

}

public void setMonth(int month)

{

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

{

this.month=month;

}

else

{

this.month=1;

}

showMonth.setText(""+month);

}

public int getMonth()

{

return month;

}

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==上月)

{

if(month>=2)

{

month=month-1;

日历.setMonth(month);

日历.设置日历牌(日历.getYear(),month);

}

else if(month==1)

{

month=12;

日历.setMonth(month);

日历.设置日历牌(日历.getYear(),month);

}

showMonth.setText(""+month);

}

else if(e.getSource()==下月)

{

if(month<12)

{

month=month+1;

日历.setMonth(month);

日历.设置日历牌(日历.getYear(),month);

}我爱编程网

else if(month==12)

{

month=1;

日历.setMonth(month);

日历.设置日历牌(日历.getYear(),month);

}

showMonth.setText(""+month);

}

}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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 保存日志,删除日志;

Hashtable table;

JLabel 信息条;

int year,month,day;

File file;

CalendarPad calendar;

public NotePad(CalendarPad calendar)

{

this.calendar=calendar;

year=calendar.getYear();

month=calendar.getMonth();

day=calendar.getDay();;

table=calendar.getHashtable();

file=calendar.getFile();

信息条=new JLabel(""+year+"年"+month+"月"+day+"日",JLabel.CENTER);

信息条.setFont(new Font("TimesRoman",Font.BOLD,16));

信息条.setForeground(Color.blue);

text=new JTextArea(10,10);

保存日志=new JButton("保存日志") ;

删除日志=new JButton("删除日志") ;

保存日志.addActionListener(this);

删除日志.addActionListener(this);

setLayout(new BorderLayout());

JPanel pSouth=new JPanel();

add(信息条,BorderLayout.NORTH);

pSouth.add(保存日志);

pSouth.add(删除日志);

add(pSouth,BorderLayout.SOUTH);

add(new JScrollPane(text),BorderLayout.CENTER);

}

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==保存日志)

{

保存日志(year,month,day);

}

else if(e.getSource()==删除日志)

{

删除日志(year,month,day);

}

}

public void setYear(int year)

{

this.year=year;

}

public int getYear()

{

return year;

}

public void setMonth(int month)

{

this.month=month;

}

public int getMonth()

{

return month;

}

public void setDay(int day)

{

this.day=day;

}

public int getDay()

{

return day;

}

public void 设置信息条(int year,int month,int day)

{

信息条.setText(""+year+"年"+month+"月"+day+"日");

}

public void 设置文本区(String s)

{

text.setText(s);

}

public void 获取日志内容(int year,int month,int day)

{

String key=""+year+""+month+""+day;

try

{

FileInputStream inOne=new FileInputStream(file);

ObjectInputStream inTwo=new ObjectInputStream(inOne);

table=(Hashtable)inTwo.readObject();

inOne.close();

inTwo.close();

}

catch(Exception ee)

{

}

if(table.containsKey(key))

{

String m=""+year+"年"+month+"月"+day+"这一天有日志记载,想看吗?";

int ok=JOptionPane.showConfirmDialog(this,m,"询问",JOptionPane.YES_NO_OPTION,

JOptionPane.QUESTION_MESSAGE);

if(ok==JOptionPane.YES_OPTION)

{

text.setText((String)table.get(key));

}

else

{

text.setText("");

}

}

else

{

text.setText("无记录");

}

}

public void 保存日志(int year,int month,int day)

{

String 日志内容=text.getText();

String key=""+year+""+month+""+day;

String m=""+year+"年"+month+"月"+day+"保存日志吗?";

int ok=JOptionPane.showConfirmDialog(this,m,"询问",JOptionPane.YES_NO_OPTION,

JOptionPane.QUESTION_MESSAGE);

if(ok==JOptionPane.YES_OPTION)

{

try

{

FileInputStream inOne=new FileInputStream(file);

ObjectInputStream inTwo=new ObjectInputStream(inOne);

table=(Hashtable)inTwo.readObject();

inOne.close();

inTwo.close();

table.put(key,日志内容);

FileOutputStream out=new FileOutputStream(file);

ObjectOutputStream objectOut=new ObjectOutputStream(out);

objectOut.writeObject(table);

objectOut.close();

out.close();

}

catch(Exception ee)

{

}

}

}

public void 删除日志(int year,int month,int day)

{

String key=""+year+""+month+""+day;

if(table.containsKey(key))

{

String m="删除"+year+"年"+month+"月"+day+"日的日志吗?";

int ok=JOptionPane.showConfirmDialog(this,m,"询问",JOptionPane.YES_NO_OPTION,

JOptionPane.QUESTION_MESSAGE);

if(ok==JOptionPane.YES_OPTION)

{

try

{

FileInputStream inOne=new FileInputStream(file);

ObjectInputStream inTwo=new ObjectInputStream(inOne);

table=(Hashtable)inTwo.readObject();

inOne.close();

inTwo.close();

table.remove(key);

FileOutputStream out=new FileOutputStream(file);

ObjectOutputStream objectOut=new ObjectOutputStream(out);

objectOut.writeObject(table);

objectOut.close();

out.close();

text.setText(null);

}

catch(Exception ee)

{

}

}

}

else

{

String m=""+year+"年"+month+"月"+day+"无日志记录";

JOptionPane.showMessageDialog(this,m,"提示",JOptionPane.WARNING_MESSAGE);

}

}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class Year extends Box implements ActionListener

{

int year;

JTextField showYear=null;

JButton 明年,去年;

CalendarPad 日历;

public Year(CalendarPad 日历)

{

super(BoxLayout.X_AXIS);

showYear=new JTextField(4);

showYear.setForeground(Color.blue);

showYear.setFont(new Font("TimesRomn",Font.BOLD,14));

this.日历=日历;

year=日历.getYear();

明年=new JButton("下年");

去年=new JButton("上年");

add(去年);

add(showYear);

add(明年);

showYear.addActionListener(this);

去年.addActionListener(this);

明年.addActionListener(this);

}

public void setYear(int year)

{

this.year=year;

showYear.setText(""+year);

}

public int getYear()

{

return year;

}

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==去年)

{

year=year-1;

showYear.setText(""+year);

日历.setYear(year);

日历.设置日历牌(year,日历.getMonth());

}

else if(e.getSource()==明年)

{

year=year+1;

showYear.setText(""+year);

日历.setYear(year);

日历.设置日历牌(year,日历.getMonth());

}

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

{

try

{

year=Integer.parseInt(showYear.getText());

showYear.setText(""+year);

日历.setYear(year);

日历.设置日历牌(year,日历.getMonth());

}

catch(NumberFormatException ee)

{

showYear.setText(""+year);

日历.setYear(year);

日历.设置日历牌(year,日历.getMonth());

}

}

}

}

希望能帮到你,以上分为4个类。。分割线以标注了

急需日历记事本JAVA源代码 用java图形用户界面实现: 编写一个日历程序,能实现显示日历等简单功能。

用java图形用户界面实现: 编写一个日历程序,能实现显示日历等简单功能。

import javax.swing.JOptionPane;

public class NewClass{

public static void main(String[] args){

int year,month;

Calender cal=new Calender(2008,10);

cal.showCalender();

year=Integer.parseInt(JOptionPane.showInputDialog("Year:"));

month=Integer.parseInt(JOptionPane.showInputDialog("Month:"));

cal.setYear(year);

cal.setMonth(month);

cal.showCalender();

}

}

class Calender{

private int year,month;

public Calender(){

year=0;

month=1;

}

public Calender(int year){

this.year=year;

month=1;

}

public Calender(int year,int month){

this.year=year;

if(month>12)

this.month=month%12;

else

this.month=month;

}

public void setYear(int year){

this.year=year;

}

public void setMonth(int month){

if(month>12)

this.month=month%12;

else

this.month=month;

}

private int dayOfMonth(){

int days=0;

switch(month){

case 1:days=31;break;

case 2:{

if(((year%4==0)&&(year%100!=0))||(year%400==0))

days=29;

else

days=28;

break;

}

case 3:days=31;break;

case 4:days=30;break;

case 5:days=31;break;

case 6:days=30;break;

case 7:days=31;break;

case 8:days=31;break;

case 9:days=30;break;

case 10:days=31;break;

case 11:days=30;break;

case 12:days=31;break;

default:

days=0;

}

return days;

}

private int dayOfWeek(){

int Y=year;

int M=month;

int D=1;

int A;

A = Y>0?(5+(Y+1)+(Y-1)/4-(Y-1)/100+(Y-1)/400)%7:(5+Y+Y/4-Y/100+Y/400)%7;

A = M>2?(A+2*(M+1)+3*(M+1)/5)%7:(A+2*(M+2)+3*(M+2)/5)%7;

if (((Y%4 == 0 && Y%100 != 0)|| Y%400 == 0) && M>2) A =(A+1)%7;

A=(A+D)%7;

return A;

}

public void showCalender(){

String str=new String();

str=" ";

str+=year+"年"+month+"月";

str+="\n\n";

str+="日 一 二 三 四 五 六\n";

int week=this.dayOfWeek();

for(int i=0,j=1;i<7;i++){

if(i

str+=" ";

else{

str+=" "+j+" ";

j++;

}

}

str+="\n";

end:

for(int i=7-week+1;i<=this.dayOfMonth();){

for(int j=0;j<7;j++){

if(i<10)

str+=" "+i+" ";

else

str+=i+" ";

i++;

if(i>this.dayOfMonth())

break end;

}

str+="\n";

}

JOptionPane.showMessageDialog(null,str);

}

}

急需日历记事本JAVA源代码 用java图形用户界面实现: 编写一个日历程序,能实现显示日历等简单功能。

用java语言编写一个万年历程序,要求只显示阳历、节日、还有农历年、闰年

我爱编程网(https://www.52biancheng.com)小编还为大家带来用java语言编写一个万年历程序,要求只显示阳历、节日、还有农历年、闰年的相关内容。

/**

* @(#)AidyCalender.java

*

*

* @author

* @version 1.00 2008/7/19

*/

import java.awt.*;

import java.awt.event.*;

import java.lang.StringBuffer;

import javax.swing.*;

import java.util.*;

import javax.swing.Timer;

import javax.swing.border.*;

public class AidyCalender extends JFrame implements ActionListener,ItemListener{

Date date = new Date();

private GregorianCalendar gregorianCalendar = new GregorianCalendar();

//定义中英文字符数组存储星期信息,用于转换显示

private String[] stringWeekEn = new String[] { "SUN", "MON", "TUE", "WED",

"THU", "FRI", "SAT" };

private String[] stringWeekCn = new String[] { "星期日", "星期一", "星期二", "星期三",

"星期四", "星期五", "星期六" };

//定义存储月份的信息数组,用于转换显示方示

private String[] stringMonthEn = new String[] { "Jan", "Feb", "Mar", "Apr",

"May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };

private String[] stringMonthCn = {"一月","二月","三月","四月","五月","六月",

"七月","八月","九月","十月","十一月","十二月"};

private String[] sysNowTime = new String[6];//sysNowTime 用于存储系统时间的变量

private String[] sysRunTime = new String[6];

private JLabel []labelWeek = new JLabel[7];

private JLabel []labelDay = new JLabel[42];

private JLabel labelTime = new JLabel();

private JPanel panel1 = new JPanel();

private JPanel panel2 = new JPanel();

private JPanel panel3 = new JPanel();

private JComboBox combo1 = new JComboBox();

private JComboBox combo2 = new JComboBox();

private JButton buttonToday = new JButton();

private Border border = BorderFactory.createRaisedBevelBorder();

private Border border1 = BorderFactory.createLineBorder(Color.cyan,3);

public AidyCalender(String title) {

super(title);

for (int y = 1900; y < 2101; y++) {

combo1.addItem(" " + new Integer(y).toString()+"年");

}

for (int m = 0;m<12;m++){

combo2.addItem(" "+stringMonthCn[m]);

}

buttonToday.setText("今 天");

setLayout(new FlowLayout());

add(panel1);

add(panel2);

add(panel3);

panel1.setLayout(new GridLayout(1,3,10,0));

panel1.add(combo1);

combo1.addItemListener(this);

panel1.add(combo2);

combo2.addItemListener(this);

panel1.add(buttonToday);

buttonToday.addActionListener(this);

labelTime.setFont(new Font("宋体",Font.PLAIN,16));

labelTime.setForeground(Color.MAGENTA);

panel1.add(labelTime);

Timer time = new Timer(1000,new TimerListener());

time.addActionListener(new TimerListener());

//time.setRepeats(true);

time.start();

//labelTime.addAncestorListener(new TimerListener());

panel2.setLayout(new GridLayout(7,7,0,10));

panel2.setBackground(Color.white);

for(int i=0;i<7;i++){

labelWeek[i] = new JLabel();

labelWeek[i].setHorizontalAlignment(0);

if(i==0||i==6){

labelWeek[i].setBackground(Color.blue);

labelWeek[i].setForeground(Color.RED);

labelWeek[i].setFont(new Font("黑体",Font.BOLD,14));

}

else{

labelWeek[i].setForeground(Color.BLACK);

labelWeek[i].setFont(new Font("新宋体",Font.PLAIN,14));

}

labelWeek[i].setText(stringWeekCn[i]);

panel2.add(labelWeek[i]);

}

for(int i= 0;i<42;i++){

labelDay[i] = new JLabel();

labelDay[i].setHorizontalAlignment(0);

labelDay[i].setText("");

panel2.add(labelDay[i]);

}

addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e){

System.exit(0);

}

});

setSize(300,300);

setBounds(250, 200, 400, 360);

setVisible(true);

setResizable(false);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

getSysDate();

setNowDate();

}

public void actionPerformed(ActionEvent ae){

if(ae.getSource()==buttonToday){

setNowDate();

}

}

public void itemStateChanged(ItemEvent aa){

setChangeDate();

}

public int turnWeek(String week){

int i;

for(i=0;i<7;i++)

if(week.equalsIgnoreCase(stringWeekEn[i]))

break;

return i;

}

public int turnMonth(String month){

/**

*int turnMonth(String month)

*@month 系统日期中的月,诸如Jan\Feb

*@return int

*返回一个整数值,用于寻找stringMonthCn[]数组中对应的中文月份

*/

int i;

for(i=0;i<12;i++)

if(month.equalsIgnoreCase(stringMonthEn[i]))

break;

return i;

}

/**

*setNowDate()

*设置当前系统日期

*/

public void setNowDate(){

setSysDate(getNowYear(),getNowMonth());

getSysRunDate();

setDateNull();

combo1.setSelectedIndex(getShowYear() - 1900);

combo2.setSelectedIndex(getShowMonth());

setDays(getMonthDays(getNowYear(),getNowMonth()),getInitWeek(sysRunTime[0]),getNowDay());

//labelTime.setText(sysNowTime[3]);

//labelTime.setHorizontalAlignment(0);

}

/**Integer getShowYear()

*获取组合框中应该显示的年份

*/

public void setSysDate(int year,int month){

gregorianCalendar.set(year,month,1);

}

public void setDateNull(){

for(int i=0;i<42;i++){

labelDay[i].setText("");

}

}

public void setChangeDate(){

setSysDate(getComboYear(),getComboMonth());

getSysRunDate();

setDateNull();

setDays(getMonthDays(getComboYear(),getComboMonth()),getInitWeek(sysRunTime[0]),-1);

}

public int getMonthDays(int year, int month) {

/**

*返回所选年月的天数,因为数组中的数值从0开始,所以3\5\8\10分别代表4\6\9\11几个小月.

*而1代表2月,经过是否为闰年判断,选择返回28或29天.

*其余月份为大月,返回31天.

**/

switch (month) {

case 3:

case 5:

case 8:

case 10:

return 30;//小月返回30天

case 1:

if (gregorianCalendar.isLeapYear(year)) {

//isLeapYear(year)确定当前纪元中的指定年份是否为闰年。

return 29;

} else {

return 28;

}//闰年的二月返回29天,平年返回28天

default:

return 31;

//大月返回31天

}

}

/**

*int getComboYear()

*获取组合框中的年份

*/

public void getSysDate(){

date = gregorianCalendar.getTime();

sysNowTime = (date.toString()).split(" ");

}

public void getSysRunDate(){

date = gregorianCalendar.getTime();

sysRunTime = (date.toString()).split(" ");

}

public int getComboYear(){

return combo1.getSelectedIndex()+1900;

}

/**

*int getComboMonth()

*获取月组合框中的整数值,

*/

public int getComboMonth(){

return combo2.getSelectedIndex();

}

public int getInitWeek(String initWeek){

/**

*getWeekNow(String initWeek)

*@para nowWeek 系统日期中的星期

*返回当月中的1号是从星期几开始

*/

int nowWeek = 0 ;

for(int i = 0;i<7;i++){

if(initWeek.equalsIgnoreCase(stringWeekEn[i])){

nowWeek = i;

break;

}

}

return nowWeek;

}

public int getNowYear(){

return Integer.parseInt(sysNowTime[5]);

}

public int getNowMonth(){

int nowMonth=0;

for(int i=0;i<12;i++){

if(sysNowTime[1].equalsIgnoreCase(stringMonthEn[i]));

nowMonth=i;

break;

}

return nowMonth;

}

public int getNowDay(){

return Integer.parseInt(sysNowTime[2]);

}

public Integer getShowYear(){

return Integer.parseInt(sysNowTime[5]);

}

public Integer getShowMonth(){

/**

*Integer getShowMonth()

*获取在组给框中显示的中文格式月份:如七月\八月等

*/

return turnMonth(sysNowTime[1]);

}

public void setDays(int monthDays,int initWeek,int day){

/**

*void setDays(int monthDays,int initWeek,int day)

*@para monthDays 本月天数

*@para initWeek 初始星期

*@para day 今天日

*设置月历

*/

setDateNull();

for(int i=initWeek;i

if((i-initWeek+1)==day){

labelDay[i].setBorder(border1);

labelDay[i].setForeground(Color.BLUE);

labelDay[i].setFont(new Font("黑体",Font.BOLD,20));

}else if((i%7==0)||(i%7==6))

labelDay[i].setForeground(Color.RED);

else{

labelDay[i].setForeground(Color.BLACK);

}

labelDay[i].setText(String.valueOf(i-initWeek+1));

}

for(int i=initWeek+monthDays;i<42;i++)

labelDay[i].setText("");

}

class TimerListener implements ActionListener{

//AdapterDemo var=new AdapterDemo("万年历程序--Aidy");

public void actionPerformed(ActionEvent e) {

GregorianCalendar g = new GregorianCalendar();

String clock = new String((g.getTime().toString().split(" "))[3]);

labelTime.setText(clock);

}

}

public static void main(String args[])

{

try{

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

}catch(Exception e){

throw new RuntimeException(e);

}

AidyCalender var=new AidyCalender("万年历程序--Aidy");

}

}

本文来自CSDN博客,转载请标明出处:

以上就是我爱编程网整理的急需日历记事本JAVA源代码 用java图形用户界面实现: 编写一个日历程序,能实现显示日历等简单功能。相关内容,想要了解更多信息,敬请查阅我爱编程网。更多相关文章关注我爱编程网:www.52biancheng.com

免责声明:文章内容来自网络,如有侵权请及时联系删除。
与“急需日历记事本JAVA源代码 用java图形用户界面实现: 编写一个日历程序,能实现显示日历等简单功能。”相关推荐