Search This Blog & Web

Tuesday, January 3, 2012

Insert NIC no Get B'day & Gender :D (Java Source Code)

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class Demo extends JFrame implements ActionListener{
JPanel panel1;
JPanel panel2;
JPanel panel3;
JPanel panel4;
JTextField display;
JLabel lbl;
JLabel lbl2;
JLabel lbl3;
JLabel lbl4;
JLabel lbl5;
JLabel lbl6;
JButton btncal;
JButton btnclr;


Demo(){
panel1=new JPanel(new FlowLayout(FlowLayout.LEFT));
panel2=new JPanel(new FlowLayout(FlowLayout.LEFT));
panel3=new JPanel();
panel4=new JPanel(new FlowLayout(FlowLayout.RIGHT));
display=new JTextField(10);
lbl=new JLabel("ID NO without V");
lbl2=new JLabel("B'Day :");
lbl3=new JLabel();
lbl4=new JLabel("Gender :");
lbl5=new JLabel();
lbl6=new JLabel("<html>CopyRight By DT Lakmal<br> All Rights Reserved");
btncal=new JButton("Calculate");
btnclr=new JButton("Clear");

panel1.add(lbl);
panel1.add(display);
panel2.add(lbl2);
panel2.add(lbl3);
panel2.add(lbl4);
panel2.add(lbl5);
panel3.add(btncal);
panel3.add(btnclr);
panel4.add(lbl6);
add(panel1,"North");
add(panel2,"Center");
add(panel3,"South");
add(panel4,"East");

btncal.addActionListener(this);
btnclr.addActionListener(this);

}
String year;
int dayNum;
int monNum;
int gen;
public void actionPerformed(ActionEvent e){
String s=display.getText();
int val=Integer.parseInt(s);
int[] x=new int[9];
int[] y={100000000,10000000,1000000,100000,10000};
for(int i=0;i<5;i++){
x[i]=val/y[i];
val=val%y[i];
}
if(e.getSource()==btncal){
year=""+x[0]+x[1];
String cal=""+x[2]+x[3]+x[4];
int intCal1=Integer.parseInt(cal);
if(intCal1>500){

gen=intCal1;

intCal1-=500;

}

int[] mon={31,29,31,30,31,30,31,31,30,31,30,31};
monNum=1;
dayNum=1;
for(int i=0;i<mon.length;i++){
if(intCal1>mon[i]){
intCal1-=mon[i];
monNum++;
}
else{
dayNum=intCal1;
}
}
if(gen>500){
lbl5.setText("Female");

}else{
lbl5.setText("Male");
}

}
lbl3.setText(""+year+"-"+monNum+"-"+dayNum);

if(e.getSource()==btnclr){
lbl3.setText("");
display.setText("");
lbl5.setText("");
}
}
public static void main(String args[]){
Demo a=new Demo();

a.setSize(350,150);
a.setVisible(true);
//a.pack();
a.setLocationRelativeTo(null);
}
}




Preview

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
Web Analytics