JAVA 编写一个日历记事本的程序 点击上月按钮 怎么没有改变呢?麻烦帮帮忙呀。。。
//下年按钮监听动作publicvoidactionPerformed(ActionEvente){if(e.getSource()==nextYear){year++;...
//下年 按钮监听动作
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==nextYear)
{
year++;
showYear.setText(""+year);
calendarMessage.setYear(year);
calendarPad.setCalendarMessage(calendarMessage);
calendarPad.showMonthCalendar();
notePad.setShowMessage(year,month,day);
doMark();
}
//上年 按钮监听动作
else if (e.getSource()==lastYear)
{
year--;
showYear.setText(""+year);
calendarMessage.setYear(year);
calendarPad.setCalendarMessage(calendarMessage);
calendarPad.showMonthCalendar();
notePad.setShowMessage(year,month,day);
doMark();
}
//下月 按钮监听动作
else if (e.getSource()==nextMonth)
{
month++;
if(month>12) month=1;
showMonth.setText(""+month);
calendarPad.setCalendarMessage(calendarMessage);
calendarPad.showMonthCalendar();
notePad.setShowMessage(year,month,day);
doMark();
}
//上月按钮监听
else if (e.getSource()==lastMonth){
month--;
if(month<1) month=12;
showMonth.setText(""+month);
calendarPad.setCalendarMessage(calendarMessage);
calendarPad.showMonthCalendar();
notePad.setShowMessage(year,month,day);
doMark();
}
//显示年份
else if (e.getSource()==showYear){
String s = showYear.getText().trim();
char a[] = s.toCharArray();
boolean boo = false;
for(int i = 0;i < a.length;i++){
if(!(Character.isDigit(a[i])))
boo = true;
}
if(boo==true)
JOptionPane.showMessageDialog(this,"你输入了非法年份","警告!", JOptionPane.WARNING_MESSAGE);
else if(boo==false)
year = Integer.parseInt(s);
showYear.setText(""+year);
calendarMessage.setYear(year);
calendarPad.setCalendarMessage(calendarMessage);
calendarPad.showMonthCalendar();
notePad.setShowMessage(year,month,day);
doMark();}
else if (e.getSource()==showMonth){
String s = showMonth.getText().trim();
char a[] = s.toCharArray();
boolean boo = false;
for(int i = 0;i < a.length;i++){
if(!(Character.isDigit(a[i])))
boo = true;
}
if(boo==true)
JOptionPane.showMessageDialog(this,"你输入了非法月份","警告!", JOptionPane.WARNING_MESSAGE);
else if(boo==false)
month = Integer.parseInt(s);
showMonth.setText(""+month);
calendarMessage.setMonth(month);
calendarPad.setCalendarMessage(calendarMessage);
calendarPad.showMonthCalendar();
notePad.setShowMessage(year,month,day);
doMark();
} 展开
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==nextYear)
{
year++;
showYear.setText(""+year);
calendarMessage.setYear(year);
calendarPad.setCalendarMessage(calendarMessage);
calendarPad.showMonthCalendar();
notePad.setShowMessage(year,month,day);
doMark();
}
//上年 按钮监听动作
else if (e.getSource()==lastYear)
{
year--;
showYear.setText(""+year);
calendarMessage.setYear(year);
calendarPad.setCalendarMessage(calendarMessage);
calendarPad.showMonthCalendar();
notePad.setShowMessage(year,month,day);
doMark();
}
//下月 按钮监听动作
else if (e.getSource()==nextMonth)
{
month++;
if(month>12) month=1;
showMonth.setText(""+month);
calendarPad.setCalendarMessage(calendarMessage);
calendarPad.showMonthCalendar();
notePad.setShowMessage(year,month,day);
doMark();
}
//上月按钮监听
else if (e.getSource()==lastMonth){
month--;
if(month<1) month=12;
showMonth.setText(""+month);
calendarPad.setCalendarMessage(calendarMessage);
calendarPad.showMonthCalendar();
notePad.setShowMessage(year,month,day);
doMark();
}
//显示年份
else if (e.getSource()==showYear){
String s = showYear.getText().trim();
char a[] = s.toCharArray();
boolean boo = false;
for(int i = 0;i < a.length;i++){
if(!(Character.isDigit(a[i])))
boo = true;
}
if(boo==true)
JOptionPane.showMessageDialog(this,"你输入了非法年份","警告!", JOptionPane.WARNING_MESSAGE);
else if(boo==false)
year = Integer.parseInt(s);
showYear.setText(""+year);
calendarMessage.setYear(year);
calendarPad.setCalendarMessage(calendarMessage);
calendarPad.showMonthCalendar();
notePad.setShowMessage(year,month,day);
doMark();}
else if (e.getSource()==showMonth){
String s = showMonth.getText().trim();
char a[] = s.toCharArray();
boolean boo = false;
for(int i = 0;i < a.length;i++){
if(!(Character.isDigit(a[i])))
boo = true;
}
if(boo==true)
JOptionPane.showMessageDialog(this,"你输入了非法月份","警告!", JOptionPane.WARNING_MESSAGE);
else if(boo==false)
month = Integer.parseInt(s);
showMonth.setText(""+month);
calendarMessage.setMonth(month);
calendarPad.setCalendarMessage(calendarMessage);
calendarPad.showMonthCalendar();
notePad.setShowMessage(year,month,day);
doMark();
} 展开
2个回答
展开全部
直接看代码很难看出问题的,需要用debug
如果可以的话 请发整个程序的源码到t19861112@126.com
如果可以的话 请发整个程序的源码到t19861112@126.com
追问
好的 我已经发了 麻烦帮忙改一下啊
追答
//下月 按钮监听动作
else if (e.getSource()==nextMonth)
{
month++;
if(month>12) month=1;
showMonth.setText(""+month);
/**
需要重新设置month的值 , 另外一个函数也一样修改下。
**/
calendarMessage.setMonth(month);
calendarPad.setCalendarMessage(calendarMessage);
calendarPad.showMonthCalendar();
notePad.setShowMessage(year,month,day);
doMark();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询