什么';天数有什么问题吗? import javax.swing.*; 导入javax.swing.text.DateFormatter; 导入java.awt.*; 导入java.awt.event.*; 导入java.text.simpleDa

什么';天数有什么问题吗? import javax.swing.*; 导入javax.swing.text.DateFormatter; 导入java.awt.*; 导入java.awt.event.*; 导入java.text.simpleDa,java,Java,什么';天数有什么问题吗? import javax.swing.*; 导入javax.swing.text.DateFormatter; 导入java.awt.*; 导入java.awt.event.*; 导入java.text.simpleDataFormat; 导入java.util.GregorianCalendar; 公共类Calendar扩展JFrame实现ActionListener{ 私有JButton Next,Previous; 私人JLabel current日期、

什么';天数有什么问题吗?
import javax.swing.*;
导入javax.swing.text.DateFormatter;
导入java.awt.*;
导入java.awt.event.*;
导入java.text.simpleDataFormat;
导入java.util.GregorianCalendar;
公共类Calendar扩展JFrame实现ActionListener{
私有JButton Next,Previous;
私人JLabel current日期、时间;
私人JLabel天数[];
私有JButton[]日按钮;
私人JPanel P1、P2、P3、P4、P5;
私有整数年、月、日、ch;
字符串S1;
GregorianCalendar GC=新的GregorianCalendar();;
int DayOfWeek=GC.get(每周的GC.DAY);
颜色c=新颜色(169,97182);
颜色c2=新颜色(24123241);
字符串[]个月={“一月”、“二月”、“三月”、“四月”、“五月”、“六月”、“七月”、“八月”、“九月”、“十月”、“十一月”、“十二月”};
日历()
{        
超级(“日历”);
年份=GC.get(GC.year);
月=GC.get(GC.month);
day=GC.get(GC.DATE);
Previous=新的JButton(“”);
下一步。挫折背景(颜色:浅灰色);
Next.addActionListener(这个);
CurrDate=新的JLabel(“+月[月]+”“+年+”);
CurrDate.setForeground(颜色:白色);
CurrDate.setFont(新字体(“衬线”,字体斜体+字体粗体,15));
CurrDate.setAlignmentX(中心对齐);
天数=新的JLabel[7];
天[0]=新的JLabel(“太阳”);
天[1]=新的JLabel(“周一”);
天[2]=新的JLabel(“星期二”);
天[3]=新的JLabel(“周三”);
天[4]=新的JLabel(“Thu”);
天[5]=新的JLabel(“周五”);
天[6]=新的JLabel(“Sat”);
用于(JLabel:天)
{
l、 设置前景(颜色:白色);
l、 setAlignmentX(左对齐);
}
时间=新的JLabel();
Time.setText(GC.get(GC.HOUR)+“:”+GC.get(GC.MINUTE)+“:”+GC.get(GC.SECOND));
时间。设置前景(颜色。白色);
如果(月=0 |月=2 |月=4 |月=6 |月=7 |月=9 |月=11)
{
ch=1;
}
其他的
{
ch=2;
}
P1=新的JPanel();
P2=新的JPanel();
P3=新的JPanel();
P4=新的JPanel();
P5=新的JPanel();
P5.setLayout(新的BorderLayout());
P1.添加(先前);
P1.添加(当前日期);
提款日历(星期日、年、月);
P1.添加(下一步);
P2.增加(天[0]);
P2.增加(天[1]);
P2.增加(天[2]);
P2.增加(天[3]);
P2.增加(天[4]);
P2.增加(天[5]);
P2.增加(天[6]);
P4.添加(时间);
P1.倒退(c);
P2.倒退(c);
P4.倒退(c);
P5.add(P1,BorderLayout.NORTH);
P5.add(P2,BorderLayout.CENTER);
添加(P5,BorderLayout.NORTH);
添加(P3,BorderLayout.CENTER);
新增(P4,南部边界布局);
}
私人日历(整数周日、整数年、整数月){
P3.设置布局(新网格布局(7,7,3,3));
dayButtons=新的JButton[49];
if(DayOfWeek==1&&ch==1)
{
对于(int i=0;i<31;i++)
{dayButtons[i]=新的JButton(i+1+“”);
P3.添加(日期按钮[i]);
dayButtons[i].addActionListener(此);
dayButtons[i].立根点(c2);
} 
对于(int i=31;i<49;i++)
{dayButtons[i]=新的JButton(“”);
P3.添加(日期按钮[i]);
dayButtons[i].addActionListener(此);
dayButtons[i].setBackground(颜色:浅灰色);
} 
}
if(DayOfWeek==2&&ch==1)
{
对于(int i=0;i<1;i++)
{dayButtons[i]=新的JButton(“”);
P3.添加(日期按钮[i]);
dayButtons[i].addActionListener(此);
dayButtons[i].setBackground(颜色:浅灰色);
} 
对于(int i=1;i<32;i++)
{dayButtons[i]=新的JButton(i+“”);
P3.添加(日期按钮[i]);
dayButtons[i].addActionListener(此);
dayButtons[i].立根点(c2);
} 
对于(int i=32;i<49;i++)
{dayButtons[i]=新的JButton(“”);
P3.添加(日期按钮[i]);
dayButtons[i].addActionListener(此);
dayButtons[i].setBackground(颜色:浅灰色);
} 
}
if(DayOfWeek==3&&ch==1)
{
对于(int i=0;i<2;i++)
{dayButtons[i]=新的JButton(“”);
P3.添加(日期按钮[i]);
dayButtons[i].addActionListener(此);
dayButtons[i].setBackground(颜色:浅灰色);
} 
对于(int i=2;i<33;i++)
{dayButtons[i]=新的JButton(i-1+);
P3.添加(日期按钮[i]);
dayButtons[i].addActionListener(此);
dayButtons[i].立根点(c2);
} 
对于(int i=33;i<49;i++)
{dayButtons[i]=新的JButton(“”);
P3.添加(日期按钮[i]);
dayButtons[i].addActionListener(此);
dayButtons[i].setBackground(颜色:浅灰色);
} 
}
if(DayOfWeek==4&&ch==1)
{
对于(int i=0;i<3;i++)
{dayButtons[i]=新的JButton(“”);
P3.添加(日期按钮[i]);
dayButtons[i].addActionListener(此);
dayButtons[i].setBackground(颜色:浅灰色);
} 
对于(int i=3;i<34;i++)
{dayButtons[i]=新的JButton(i-2+);
P3.添加(日期按钮[i]);
dayButtons[i].addActionListener(此);
dayButtons[i].立根点(c2);
} 
for(int i=34;i<49;i++)
{dayButtons[i]=新的JButton(“”);
P3.添加(日期按钮[i]);
dayButtons[i].addActionListener(此);
dayButtons[i].setBackground(颜色:浅灰色);
} 
}
如果(星期五==5&&ch==1)
{
对于(int i=0;i<4;i++)
{dayButtons[i]=新的JButton(“”);
P3.添加(日期按钮[i]);
dayButtons[i].addActionListener(此);
dayButtons[i].setBackground(颜色:浅灰色);
} 
对于(int i=4;i<35;i++)
{dayButtons[i]=新的JButton
import javax.swing.*;
import javax.swing.text.DateFormatter;
import java.awt.*;
import java.awt.event.*;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;

 public class Calendar extends JFrame implements ActionListener {
private JButton Next, Previous;
private JLabel CurrDate,Time;
private JLabel Days[];
private JButton [] dayButtons;
private JPanel P1,P2,P3,P4,P5;
private int year , month , day ,ch;
String S1;
GregorianCalendar GC=new GregorianCalendar();;
int DayOfWeek=GC.get(GC.DAY_OF_WEEK);

Color c = new Color(169,97,182);
Color c2 = new Color(241,233,241);
String[] months =  {"January", "February", "March", "April", "May", "June", "July",    "August", "September", "October", "November", "December"};
Calendar()
{        
    super( "Calendar" );

    year = GC.get(GC.YEAR);
    month = GC.get(GC.MONTH);
    day = GC.get(GC.DATE);


    Previous = new JButton ("<<");
    Previous.setBackground(Color.LIGHT_GRAY);
    Previous.addActionListener(this);
    Next = new JButton (">>");
    Next.setBackground(Color.LIGHT_GRAY);
    Next.addActionListener(this);

    CurrDate = new JLabel ("                   "+ months[month]+"        "+year+"               ");
    CurrDate.setForeground(Color.WHITE);
    CurrDate.setFont(new Font ("Serif",Font.ITALIC+Font.BOLD,15));
    CurrDate.setAlignmentX(CENTER_ALIGNMENT);
    Days = new JLabel[7];
    Days[0] = new JLabel ("Sun         ");
    Days[1] = new JLabel ("Mon         ");
    Days[2] = new JLabel ("Tue         ");
    Days[3] = new JLabel ("Wed         ");
    Days[4] = new JLabel ("Thu         ");
    Days[5] = new JLabel ("Fri            ");
    Days[6] = new JLabel ("Sat         ");
    for(JLabel l : Days)
    {
        l. setForeground(Color.WHITE);
        l.setAlignmentX(LEFT_ALIGNMENT);
    }
    Time = new JLabel ();
    Time.setText(GC.get(GC.HOUR)+":"+GC.get(GC.MINUTE)+":"+GC.get(GC.SECOND));
    Time.setForeground(Color.WHITE);
    if( month ==0 || month ==2 || month == 4 || month ==6 || month==7 || month ==9 || month ==11)
    {
        ch = 1;
    }
    else
    {
        ch = 2;
    }

    P1 = new JPanel();
    P2 = new JPanel();
    P3 = new JPanel();
    P4 = new JPanel();
    P5 = new JPanel();
    P5.setLayout(new BorderLayout());
    P1.add(Previous); 
    P1.add(CurrDate);   
    DrawCalendar(DayOfWeek,year,month);
    P1.add(Next);
    P2.add(Days[0]);
    P2.add(Days[1]);
    P2.add(Days[2]);
    P2.add(Days[3]);
    P2.add(Days[4]);
    P2.add(Days[5]);
    P2.add(Days[6]);

    P4.add(Time);
    P1.setBackground(c);
    P2.setBackground(c);
    P4.setBackground(c);

    P5.add (P1, BorderLayout.NORTH);
    P5.add (P2, BorderLayout.CENTER);
    add (P5,BorderLayout.NORTH);
    add (P3, BorderLayout.CENTER);
    add (P4, BorderLayout.SOUTH);
    }

private void DrawCalendar(int DayOfWeek, int year, int month) {
    P3.setLayout( new GridLayout(7,7,3,3));
    dayButtons = new JButton [49];


    if(DayOfWeek == 1 && ch ==1)
    {
        for ( int i = 0; i < 31; i++ )
         { dayButtons[ i ] = new JButton(  i+1 +"" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(c2);
         } 
        for ( int i = 31; i < 49; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
    }
    if(DayOfWeek == 2 && ch ==1)
    {
        for ( int i = 0; i < 1; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
        for ( int i = 1; i < 32; i++ )
         { dayButtons[ i ] = new JButton(  i +"" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(c2);
         } 
        for ( int i = 32; i < 49; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
    }
    if(DayOfWeek == 3 && ch ==1)
    {
        for ( int i = 0; i < 2; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
        for ( int i =2; i < 33; i++ )
         { dayButtons[ i ] = new JButton(  i-1 +"" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(c2);
         } 
        for ( int i = 33; i < 49; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
    }
    if(DayOfWeek == 4 && ch ==1)
    {
        for ( int i = 0; i < 3; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
        for ( int i =3; i < 34; i++ )
         { dayButtons[ i ] = new JButton(  i-2 +"" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(c2);
         } 
        for ( int i = 34; i < 49; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
    }
    if(DayOfWeek == 5 && ch ==1)
    {
        for ( int i = 0; i < 4; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
        for ( int i =4; i < 35; i++ )
         { dayButtons[ i ] = new JButton(  i-3 +"" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(c2);
         } 
        for ( int i = 35; i < 49; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
    }
    if(DayOfWeek == 6 && ch ==1)
    {
        for ( int i = 0; i < 5; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
        for ( int i =5; i < 36; i++ )
         { dayButtons[ i ] = new JButton(  i-4 +"" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(c2);
         } 
        for ( int i = 36; i < 49; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
    }
    if(DayOfWeek == 7 && ch ==1)
    {
        for ( int i = 0; i < 6; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
        for ( int i =6; i < 37; i++ )
         { dayButtons[ i ] = new JButton(  i-5 +"" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(c2);
         } 
        for ( int i = 37; i < 49; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
    }
    if(DayOfWeek == 1 && ch ==2)
    {
        for ( int i = 0; i < 30; i++ )
         { dayButtons[ i ] = new JButton( i+1+"" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(c2);
         } 
        for ( int i = 30; i < 49; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 

    }
    if(DayOfWeek == 2 && ch ==2)
    {
        for ( int i = 0; i < 1; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
        for ( int i =1; i < 31; i++ )
         { dayButtons[ i ] = new JButton(  i +"" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(c2);
         } 
        for ( int i = 31; i < 49; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
    }
    if(DayOfWeek == 3 && ch ==2)
    {
        for ( int i = 0; i < 2; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
        for ( int i =2; i < 32; i++ )
         { dayButtons[ i ] = new JButton(  i-1 +"" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(c2);
         } 
        for ( int i = 32; i < 49; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
    }
    if(DayOfWeek == 4 && ch ==2)
    {
        for ( int i = 0; i < 3; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
        for ( int i =3; i < 33; i++ )
         { dayButtons[ i ] = new JButton(  i-2 +"" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(c2);
         } 
        for ( int i = 33; i < 49; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
    }
    if(DayOfWeek == 5 && ch ==2)
    {
        for ( int i = 0; i < 4; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
        for ( int i =4; i < 35; i++ )
         { dayButtons[ i ] = new JButton(  i-3 +"" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(c2);
         } 
        for ( int i = 35; i < 49; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
    }
    if(DayOfWeek == 6 && ch ==2)
    {
        for ( int i = 0; i < 5; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
        for ( int i =5; i < 36; i++ )
         { dayButtons[ i ] = new JButton(  i-4 +"" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(c2);
         } 
        for ( int i = 36; i < 49; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
    }
    if(DayOfWeek == 7 && ch ==2)
    {
        for ( int i = 0; i < 6; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
        for ( int i =6; i < 37; i++ )
         { dayButtons[ i ] = new JButton(  i-5 +"" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(c2);
         } 
        for ( int i = 37; i < 49; i++ )
         { dayButtons[ i ] = new JButton( "" ); 
         P3.add( dayButtons[ i ] );
         dayButtons[i].addActionListener(this);
         dayButtons[i].setBackground(Color.LIGHT_GRAY);
         } 
    }
    for( int i = DayOfWeek-1; i<49 ; i++)
    {
        if( i- DayOfWeek+2 == GC.get(GC.DATE))
        {
            dayButtons[i].setBackground(c);
        }
    }


}


public void actionPerformed(ActionEvent arg0) {


    if(arg0.getSource()== Previous)
    {   clear();


        if(month !=0)
        {
            month --;

            if( month ==0 || month ==2 || month == 4 || month ==6 || month==7 || month ==9 || month ==11)
            {
                ch=1;
            }
            else
            {
                ch=2;
            }

        }
        else
        {
            year--;
            month=11;
            ch=1;
        }
        CurrDate.setText ("                   "+ months[month]+"        "+year+"               ");
        GregorianCalendar cal = new GregorianCalendar(year, month, 1);
        int d=cal.get(cal.DAY_OF_WEEK);
        DayOfWeek=d;
        DrawCalendar(d,year,month);

        P4.add(Time);
        P1.setBackground(c);
        P2.setBackground(c);
        P4.setBackground(c);
    }
    if(arg0.getSource()== Next)
    {
        clear();

        if(month !=11)
        {
            month ++;
            if( month ==0 || month ==2 || month == 4 || month ==6 || month==7 || month ==9 || month ==11)
            {
                ch=1;
            }
            else
            {
                ch=2;
            }
        }
        else
        {
            year++;
            month=0;
            ch=1;

        }
        CurrDate.setText ("                   "+ months[month]+"        "+year+"               ");
        GregorianCalendar cal = new GregorianCalendar(year, month, 1);
        int d=cal.get(cal.DAY_OF_WEEK);
        DayOfWeek=d;
        DrawCalendar(d,year,month);
        P4.add(Time);
        P1.setBackground(c);
        P2.setBackground(c);
        P4.setBackground(c);

    }   
    for( int i=DayOfWeek-1; i<30+DayOfWeek; i++)
    {
        if(arg0.getSource()==dayButtons[i])
        {
            S1 = JOptionPane.showInputDialog(this,"Insert your Note");

        }
    }


}

private void clear() {
    for(int i =0; i<6;i++)
    {
        for(int j=0;j<7;j++)
        {
            P3.removeAll();
        }
    }

}

public static void main(String [] args){
    Calendar C = new Calendar();
    C.setSize(400,315);

    C.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    C.setVisible(true);
    C.setResizable(false);
    }


}
private void tripleDraw (int n1, int n2, int d) 
{
    for (int i = 0; i < n1; i++)
    { 
        dayButtons [i] = new JButton (""); 
        P3.add (dayButtons [i]);
        dayButtons [i].setBackground (Color.LIGHT_GRAY);
    } 
    for (int i = n1; i < n2; i++)
    {
        dayButtons [i] = new JButton (i+d + ""); 
        P3.add (dayButtons [i]);
        dayButtons [i].setBackground (c2);
    } 
    for (int i = n2; i < 49; i++)
    { 
        dayButtons [i] = new JButton (""); 
        P3.add (dayButtons [i]);
        dayButtons [i].setBackground (Color.LIGHT_GRAY);
    } 
}

private void DrawCalendar (int DayOfWeek, int year, int month) 
{
    P3.setLayout (new GridLayout (7, 7, 3, 3));
    dayButtons = new JButton [49];

    if (DayOfWeek == 1 && ch == 1)  tripleDraw (0, 31, 1);
    if (DayOfWeek == 2 && ch == 1)  tripleDraw (1, 32, 0);
    if (DayOfWeek == 3 && ch == 1)  tripleDraw (2, 33, -1);
    if (DayOfWeek == 4 && ch == 1)  tripleDraw (3, 34, -2);
    if (DayOfWeek == 5 && ch == 1)  tripleDraw (4, 35, -3);
    if (DayOfWeek == 6 && ch == 1)  tripleDraw (5, 36, -4);
    if (DayOfWeek == 7 && ch == 1)  tripleDraw (6, 37, -5);  

    if (DayOfWeek == 1 && ch == 2)  tripleDraw (0, 30, 1);
    if (DayOfWeek == 2 && ch == 2)  tripleDraw (1, 31, 0);
    if (DayOfWeek == 3 && ch == 2)  tripleDraw (2, 32, -1);
    if (DayOfWeek == 4 && ch == 2)  tripleDraw (3, 33, -2);
    if (DayOfWeek == 5 && ch == 2)  tripleDraw (4, 35, -3);
    if (DayOfWeek == 6 && ch == 2)  tripleDraw (5, 36, -4);
    if (DayOfWeek == 7 && ch == 2)  tripleDraw (6, 37, -5);  
 if (ch == 1)  tripleDraw (DayOfWeek - 1, DayOfWeek + 31, 2-DayOfWeek);