Simple Calendar program Without using any Predefined Classes in java


Here i'm providing a calendar with using of the swing and awt and without using any of predefined classes. First you have compile run the program and then you have to enter the date like day,month and year and the application shows you the exact week of that date.it is simple but it is useful to those who are in basic learner of core java and studying students. 






//Calender

package muni.java;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Calender extends JFrame implements ActionListener
{
 JLabel l1,l2,l3,l4;
 JButton b,b1;
 JTextField t1,t2,t3;
 Container c;
 ImageIcon i1,i2,i3,i4,i5,i6,i7;
 Calender()
 {
  c=getContentPane();
  c.setLayout(new FlowLayout());
  l1=new JLabel("Enter year    :");
  l2=new JLabel("Enter month:");
  l3=new JLabel("Enter date    :");
  l4=new JLabel();
  t1=new JTextField(4);
  t2=new JTextField(2);
  t3=new JTextField(2);
  i1=new ImageIcon("sun.jpg");
  i2=new ImageIcon("mon.jpg");
  i3=new ImageIcon("tue.jpg");
  i4=new ImageIcon("wed.jpg");
  i5=new ImageIcon("thu.jpg");
  i6=new ImageIcon("fri.jpg");
  i7=new ImageIcon("sat.jpg");
  b=new JButton("Show Day");
  b1=new JButton("calculator"); 
  c.add(l1);  c.add(t1);
  c.add(l2);  c.add(t2);
  c.add(l3);  c.add(t3); 
  c.add(b); 
  c.add(l4);
  c.add(b1);
  b.addActionListener(this);
  b1.addActionListener(new Calculator());
  
 }
 
 public void actionPerformed(ActionEvent ae)
 { String a=ae.getActionCommand();
  int x,y,z=0,p,q,r=0,s,t,i,j;
  if(a.equals("Show week"));
  { 
   try
   {
   x=Integer.parseInt(t1.getText());
   y=x%100;
   q=y/4;
   if(x>1600 && x<1699  ||  x>2000 && x<2099){z=z+6;}
   if(x>1700 && x<1799  ||  x>2100 && x<2199){z=z+4;}
   if(x>1800 && x<1899  ||  x>2200 && x<2299){z=z+2;}
   if(x>1900 && x<1999  ||  x>2300 && x<2399){z=z+0;}
   p=Integer.parseInt(t2.getText());
   if(p==1 || p==10){r=r+0;}
   if(p==2 || p==3 || p==11){r=r+3;}
   if(p==4 || p==7){r=r+6;}
   if(p==5){r=r+1;}
   if(p==6){r=r+4;}
   if(p==8){r=r+2;}
   if(p==9 || p==12){r=r+5;}
   s=Integer.parseInt(t3.getText());
   i=y+s+q+z+r;
   j=i%7;
   if(j==0){l4.setIcon(i1);} 
   if(j==1){l4.setIcon(i2);}
   if(j==2){l4.setIcon(i3);}
   if(j==3){l4.setIcon(i4);}
   if(j==4){l4.setIcon(i5);}
   if(j==5){l4.setIcon(i6);}
   if(j==6){l4.setIcon(i7);}
   }
   catch(Exception e)
   {
    l4.setText("Enter Numerics Only");
   }
  }

 }
 public static void main(String a[])
 {
  Calender o=new Calender();
  o.setSize(250,250);
  o.setVisible(true);
  o.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  o.setTitle("CALENDER");
 }

}
}