Hello all,
I am stuck with a nullpointerException at line 41 and 60.Can someone please help me out.any kind of help will be appreciated.
Thanks
import javax.swing.*;
import javax.swing.event.*;
import java.awt.Color;
import java.awt.*;
class calenders extends JFrame
{
int i=0;
int j=0;
int k=0;
JFrame jf;
FlowLayout fl;
JPanel jp[];
JButton jb [];
JButton jb3[];
Button b[];
calenders()
{
jf=new JFrame ("Happy 2014 :-)");
fl=new FlowLayout();
b=new Button[12];
jp=new JPanel[12];
String days[]={"Sun", "Mon","Tue", "Wed", "Thurs", "Fri", "Sat"};
String months[]={"Jan", "Feb","March", "Apr", "May", "July", "August","september","october","november","december"};
//JButton jb1=new JButton("Previous");
//JButton jb2=new JButton("Next");
jb3=new JButton[7];
String dates[]={"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20",
"21","22","23","24","25","26","27","28","29","30","31"};
jb=new JButton[31];
Color colors[]={Color.blue, Color.yellow, Color.pink, Color.red, Color.orange, Color.white, Color.blue, Color.green, Color.pink,
Color.magenta, Color.darkGray,Color.cyan};
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setSize(800,800);
CardLayout cl=new CardLayout();
for( i=0; i<13; i++)
{
jp=new JPanel[12];
b[i]=new Button(months[i]);
b[i].setBounds(30,30,770,55);
jp[i].add(b[i]);
for(j=0; j<days.length; j++)
{
jb3[j]=new JButton(days[j]);
jp[i].add(jb3[j]);
}
for(k=0; k<dates.length; k++)
{
jb[k]=new JButton(dates[k]);
jp[i].add(jb[k]);
}
}
jp[i].setLayout(fl);
jp[i].setBackground(colors[i]);
add(jp[i],cl);
setVisible(true);
}
public static void main(String...s)
{
new calenders();
}
}