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);
      }
  }   
}

解决方案 »

  1.   

    就是中文解释这些东西 怎么给别人解释
      

  2.   

    我需要期末答辩,所以我不了解     我该怎么跟大家说~~   
      

  3.   

    你把每一行的代码都写上注释,就知道该怎么给别人解释你的代码了
      

  4.   


    +1把代码都搞懂就知道怎么解释了
      

  5.   

    我需要答辩啊  姐姐们
      

  6.   

    你就和大家说 ,这是个日历控件