1. package test; 
  2.  
  3. import java.awt.*; 
  4. import java.awt.event.*; 
  5. import java.util.*; 
  6.  
  7. public class CalendarFrame extends Frame implements ActionListener 
  8.     public static void main(String[] args) 
  9.     { 
  10.         new CalendarFrame(); 
  11.     } 
  12.      
  13.     Dimension dimension=Toolkit.getDefaultToolkit().getScreenSize();//获取屏幕Size 
  14.     int x=dimension.width,y=dimension.height;//定义两个变量x和y存储屏幕的width和height 
  15.     int n=1
  16.     Panel northPanel=new Panel(new FlowLayout());//定义一个名为northPanel的Panel放下面两个Button 
  17.     Panel centerPanel=new Panel(new GridLayout(7,7));// 
  18.     Panel southPanel=new Panel(new FlowLayout());    
  19.     Button previousMonth=new Button("PreviousMonth");//单击事件为 上一个月 
  20.     Button nextMonth=new Button("NextMonth");//单击事件为 下一个月 
  21.     CalendarFrame() 
  22.     { 
  23.         setBounds(x/2-125, y/2-175200300);//设置窗体位置、大小 
  24.         setLayout(new BorderLayout());//设置窗体布局 
  25.          
  26.         add(northPanel,BorderLayout.NORTH);//添加northPanel 
  27.         add(centerPanel,BorderLayout.CENTER); 
  28.         add(southPanel,BorderLayout.SOUTH); 
  29.         northPanel.add(previousMonth); 
  30.         northPanel.add(nextMonth); 
  31.         centerPanel.setBounds(00250250); 
  32.         southPanel.add(new Label("日历:This is time area!")); 
  33.         for(int i=0;i<=6;i++){ 
  34.             for(int j=0;j<=6;j++){   
  35.                 if(i==0){ 
  36.                     centerPanel.add(new Button("OK")); 
  37.                 } 
  38.                 else { 
  39.                     centerPanel.add(new Label("Label")); 
  40.                 } 
  41.             } 
  42.         } 
  43.         addWindowListener(new WindowAdapter() 
  44.         { 
  45.             public void windowClosing(WindowEvent e) 
  46.             { 
  47.                 System.exit(0); 
  48.             } 
  49.         }); 
  50.          
  51.         setVisible(true); 
  52.         this.validate(); 
  53.     } 
  54.  
  55.     public void actionPerformed(ActionEvent e) 
  56.     { 
  57.         // TODO Auto-generated method stub 
  58.          
  59.     } 
  60. class CalenderClass extends Frame{ 
  61.     CalendarFrame calendarFrame=new CalendarFrame(); 
  62.     Calendar calendar=Calendar.getInstance(); 
  63.     int weekDay; 
  64.     CalenderClass(int year,int month,int day){ 
  65.         calendar.set(year, month, day); 
  66.         weekDay=calendar.get(Calendar.DAY_OF_WEEK); 
  67.         String a[]=new String[weekDay+31];       
  68.         for(int i=0;i<weekDay;i++){ 
  69.              
  70.         } 
  71.     }