////////////////////////////////////////////////////
this.calendar = calendar;
today = calendar.get(Calendar.DAY_OF_MONTH);
int month = calendar.get(Calendar.MONTH);
int weekindexDay;
int weekindexMonth;
calendar.set(Calendar.DATE,1);
while(calendar.get(Calendar.MONTH)==month)
{ weekindexMonth=calendar.get(Calendar.WEEK_OF_MONTH)-1;
weekindexDay=calendar.get(Calendar.DAY_OF_WEEK)-1;
int day=calendar.get(Calendar.DAY_OF_MONTH);
///////////////////////////////////////////////
String today_,month_;
today_ =day < 10? "0" + day:"" + day;
month_ =month<10? "0" +(month+1):""+(month+1);
Lunar lunar = new Lunar(calendar);
String lunar_= lunar.toString();
///////////////////////////////////////////
if( null != sFestival.get(month_+today_))
lunar_="<font color=red>"+sFestival.get(month_+today_);
///////
String wFestival_=month_+(weekindexMonth)+(weekindexDay);
if( null != wFestival.get(wFestival_)){
lunar_="<font color=red>"+wFestival.get(wFestival_);
System.out.println(wFestival_);
}
if( null != lFestival.get(lunar.numeric_md()))
lunar_="<font color=red>"+lFestival.get(lunar.numeric_md());
//计算除夕
Calendar temp_calendar = Calendar.getInstance();
temp_calendar.set(calendar.get(Calendar.YEAR),month,day+1);
//temp_calendar.add(Calendar.DAY_OF_MONTH,1);
Lunar temp_lunar = new Lunar(temp_calendar);
String temp_str = temp_lunar.numeric_md();
if(temp_str.equals("0101"))
lunar_="<font color=red>"+lFestival.get("1299");
///计算除夕结束
//////////////////////////////////////////
String day_str;
if(day<10) day_str="<html><center><font size=6>"+today_;
else day_str="<html><center><font size=6>"+today_;
day_str+="</font><br>"+lunar_;
if(day==today)
datas[weekindexMonth][weekindexDay].setForeground(Color.GREEN);
datas[weekindexMonth][weekindexDay].setText(day_str);
calendar.add(Calendar.DATE,1);
}
/////////////////////////////////////////////////
}
public void actionPerformed(ActionEvent e){//日期和年份的选择更新
int year = Integer.parseInt(year_box.getSelectedItem().toString()) ;
int month= Integer.parseInt(month_box.getSelectedItem().toString())-1 ;
calendar.set(year,month,today);
clear_Data();
initializtion_Data(calendar);
}
class LookAndFeel_Listener implements ActionListener{//选择外观的样式
public void actionPerformed(ActionEvent ev){
JRadioButton o = (JRadioButton)ev.getSource();
String str=o.getText();
if("c" == str){
try {UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch(Exception e) { e.printStackTrace(); }
}else if("s" == str){
try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {e.printStackTrace();}
}else if("m" == str){
try{UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");}
catch(Exception e) {e.printStackTrace(); }
}
SwingUtilities.updateComponentTreeUI(Simple_Calendar.this);
}
}
class Statement_Listener implements ActionListener{//显示声明信息
JDialog dialog=null;
public void actionPerformed(ActionEvent ev){
String statment = "<html>阴历及节日程序 2008 beta1";
statment +="<br>免费软件(Free Software) 你可以无限传播与反编译.";
statment +="<br>该日历有三种外观样式,有从1900年至2049年间的所有阴历.";
statment +="<br>个人爱好开发 作者:朱春 Email:npuxbd@163.com";
statment +="<br>Copyright @ 2008- All Rights Reserved";
dialog=new JDialog(Simple_Calendar.this, "阴历及节日软件 2008 beta1",true);
dialog.setLayout(null);
dialog.setBounds(285,215,365,185);
JLabel label_s = new JLabel(statment);//label_s.setBackground(Color.RED);
JButton button=new JButton("确 定");
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evet){
dialog.setVisible(false);
}
});
dialog.add(label_s);label_s.setBounds(20,0,365,100);
dialog.add(button); button.setBounds(145,110,65,25);
dialog.setVisible(true);
}
}
class List_MouseListener implements MouseListener{//鼠标移入时显示的信息
JLabel labe=null;
String weeks[]={"星期日","星期一","星期二","星期三",
"星期四","星期五","星期六"};
public String constellation(Calendar cal){
String [][]con ={
{"水瓶座","0122","0221"},
{"双鱼座","0222","0321"},
{"白羊座","0322","0420"},
{"金牛座","0421","0521"},
{"双子座","0522","0621"},
{"巨蟹座","0621","0721"},
{"狮子座","0722","0821"},
{"处女座","0822","0921"},
{"天秤座","0922","1021"},
{"天蝎座","1022","1121"},
{"射手座","1122","1221"},
{"摩羯座","1222","0121"}};
int month=cal.get(Calendar.MONTH)+1;
int today=cal.get(Calendar.DAY_OF_MONTH);
String month_str=month<10?"0"+month:""+month;
String today_str=today<10?"0"+today:""+today;
String str=month_str+today_str;
for( int i = 0 ; i < con.length-1 ; i++ )
{
if(Integer.parseInt(str) >= Integer.parseInt(con[i][1]) && Integer.parseInt(str) <= Integer.parseInt(con[i][2]))
return con[i][0];
}
if((Integer.parseInt(str) >= Integer.parseInt(con[11][1]) && Integer.parseInt(str) < 1232) || Integer.parseInt(str) <=Integer.parseInt( con[11][2]) )
return con[11][0];
return "error!";
}
public void mouseClicked(MouseEvent e) {//鼠标按键在组件上单击(按下并释放)时调用。
}
public void mouseEntered(MouseEvent e) {//鼠标进入到组件上时调用。
labe=(JLabel)e.getSource();
String lab =labe.getText();
if(lab != ""){
labe.setBackground(Color.red);
String day=lab.substring(lab.indexOf("size=6>")+7,lab.indexOf("</font>"));
//String lun=lab.substring(lab.indexOf("<br>")+4);
String message = "<html><body><center>公元 "+year_box.getSelectedItem()+"年"+
month_box.getSelectedItem()+"月"+Integer.parseInt(day)+"日";
calendar.set(Integer.parseInt(year_box.getSelectedItem().toString()),
Integer.parseInt(month_box.getSelectedItem().toString())-1,
Integer.parseInt(day));
Lunar lunar=new Lunar(calendar);
message+="<br><font color=red>"+weeks[(calendar.get(calendar.DAY_OF_WEEK)-1)];
message+=" "+constellation(calendar)+"</font><br>农历 ";
message+=lunar.get_month()+"月"+lunar.get_Big_Or_Small()+" "+lunar.get_date()+"日";
//message+=lunar.get_JQ();
labe.setToolTipText(message);
labe.setBackground(Color.BLUE);
labe.setOpaque(true);
// System.out.println(day+":"+lun);
}
}
public void mouseExited(MouseEvent e) {// 鼠标离开组件时调用。
labe.setBackground(null);
labe.setOpaque(true);
}
public void mousePressed(MouseEvent e) {// 鼠标按键在组件上按下时调用。
}
public void mouseReleased(MouseEvent e) {// 鼠标按钮在组件上释放时调用。
}
}
/////////////////////////////////////////////////////////
private JLabel datas[][]=new JLabel[6][7];//显示一月的日期
private JLabel temp_label=null;
private JLabel label=null;
private JPanel panel_Header,panel_Week,panel_Calendar;
private Calendar calendar=null;
private JComboBox year_box = null ;
private JComboBox month_box = null ;
private int today ;
private JRadioButton cross=null,system=null,motif=null;
private ButtonGroup feel_group=null;
private JButton show_help =null;
}
本文导航
- 第1页: 首页
- 第2页: 比较阴历阳历2
- 第3页: 比较阴历阳历3