import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Frame1 extends JFrame
{
JComboBox c1=new JComboBox();
JComboBox c2=new JComboBox();
JComboBox c3=new JComboBox();
JComboBox c4=new JComboBox();
JComboBox c5=new JComboBox();
JComboBox c6=new JComboBox();
JButton b1=new JButton("OK");
JLabel l1=new JLabel("Age:");
Frame1()
{
setSize(700,550);
setDefaultCloseOperation(3);
setLayout(null);
c1.setBounds(20,20,150,40);add(c1);
for(int i=1;i<=31;i++)
{
c1.addItem(i);
}
c2.setBounds(180,20,150,40);add(c2);
for(int i=1;i<=12;i++)
{
c2.addItem(i);
}
c3.setBounds(340,20,150,40);add(c3);
for(int i=1960;i<=2040;i++)
{
c3.addItem(i);
}
c4.setBounds(20,150,150,40);add(c4);
for(int i=1;i<=31;i++)
{
c4.addItem(i);
}
c5.setBounds(180,150,150,40);add(c5);
for(int i=1;i<=12;i++)
{
c5.addItem(i);
}
c6.setBounds(340,150,150,40);add(c6);
for(int i=1960;i<=2040;i++)
{
c6.addItem(i);
}
b1.setBounds(500,150,150,40);add(b1);
l1.setBounds(20,270,400,40);add(l1);
l1.setFont(new Font("Arial",1,30));
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1();
}
});
}
void f1()
{
int d1=Integer.parseInt(c1.getSelectedItem()+"");
int m1=Integer.parseInt(c2.getSelectedItem()+"");
int y1=Integer.parseInt(c3.getSelectedItem()+"");
int d2=Integer.parseInt(c4.getSelectedItem()+"");
int m2=Integer.parseInt(c5.getSelectedItem()+"");
int y2=Integer.parseInt(c6.getSelectedItem()+"");
int d=d1-d2;
int m=m1-m2;
int y=y1-y2;
if(d<0)
{
d=d+30;
m--;
}
if(m<0)
{
m=m+12;
y--;
}
l1.setText(y+"Years "+m+" Month "+d+" Days");
}
}
class AgeCalculator
{
public static void main(String[] aa)
{
Frame1 f=new Frame1();
f.setVisible(true);
}
}