- package test;
- import java.awt.*;
- import java.awt.event.*;
- import java.util.*;
- public class CalendarFrame extends Frame implements ActionListener
- {
- public static void main(String[] args)
- {
- new CalendarFrame();
- }
- Dimension dimension=Toolkit.getDefaultToolkit().getScreenSize();//获取屏幕Size
- int x=dimension.width,y=dimension.height;//定义两个变量x和y存储屏幕的width和height
- int n=1;
- Panel northPanel=new Panel(new FlowLayout());//定义一个名为northPanel的Panel放下面两个Button
- Panel centerPanel=new Panel(new GridLayout(7,7));//
- Panel southPanel=new Panel(new FlowLayout());
- Button previousMonth=new Button("PreviousMonth");//单击事件为 上一个月
- Button nextMonth=new Button("NextMonth");//单击事件为 下一个月
- CalendarFrame()
- {
- setBounds(x/2-125, y/2-175, 200, 300);//设置窗体位置、大小
- setLayout(new BorderLayout());//设置窗体布局
- add(northPanel,BorderLayout.NORTH);//添加northPanel
- add(centerPanel,BorderLayout.CENTER);
- add(southPanel,BorderLayout.SOUTH);
- northPanel.add(previousMonth);
- northPanel.add(nextMonth);
- centerPanel.setBounds(0, 0, 250, 250);
- southPanel.add(new Label("日历:This is time area!"));
- for(int i=0;i<=6;i++){
- for(int j=0;j<=6;j++){
- if(i==0){
- centerPanel.add(new Button("OK"));
- }
- else {
- centerPanel.add(new Label("Label"));
- }
- }
- }
- addWindowListener(new WindowAdapter()
- {
- public void windowClosing(WindowEvent e)
- {
- System.exit(0);
- }
- });
- setVisible(true);
- this.validate();
- }
- public void actionPerformed(ActionEvent e)
- {
- // TODO Auto-generated method stub
- }
- }
- class CalenderClass extends Frame{
- CalendarFrame calendarFrame=new CalendarFrame();
- Calendar calendar=Calendar.getInstance();
- int weekDay;
- CalenderClass(int year,int month,int day){
- calendar.set(year, month, day);
- weekDay=calendar.get(Calendar.DAY_OF_WEEK);
- String a[]=new String[weekDay+31];
- for(int i=0;i<weekDay;i++){
- }
- }
- }