Welcome guys..

This is programmer sharing his collection with all you ppl out there. This blog contains complete codes of java , c , c++ , unix , java script , applets , swing for learning purpose only. I try to add approx 10 new complete codes daily. Lets share out knowledge and materials in here. All your comments and votes are most welcomed.

Get your codes from..

Thursday, May 8, 2008

Payrole Management System( java-applets)

import java.io.*;
import java.awt.*;
import java.awt.Color.*;
import java.awt.event.*;
import java.applet.*;


/*put this code inside applet tag---> code=train2.class height=300 width=600*/


public class train2 extends Applet implements
ActionListener,ItemListener

{
Label name,amount,seats,number;
TextField na,am,sts,nr;
TextArea t;
Choice css;

Checkbox si,sr;
CheckboxGroup g;

Button b,cancel;
int s,c,d;
int n1=400;
int n2=250;
int n3=100;

public void init()
{
setBackground(Color.yellow);
setForeground(Color.red);
setLayout(new FlowLayout());

na=new TextField(20);
am=new TextField(20);
sts=new TextField(20);
nr=new TextField(20);


name=new Label("NAME");
amount=new Label("AMOUNT");
seats=new Label("SEATS");
number=new Label("REQUIRED NO OF SEATS");

css=new Choice();
css.add("A.C SLEEPER");
css.add("FIRST CLASS");
css.add("SECOND CLASS");

t=new TextArea(40,45);

g=new CheckboxGroup();
si=new Checkbox("SATAPTI",g,false);
sr=new Checkbox("SABARI",g,false);

b=new Button("SUBMIT");
cancel=new Button("CANCEL");

add(name);
add(na);

add(seats);
add(sts);

add(number);
add(nr);


add(si);
add(sr);

add(css);

add(b);

add(amount);
add(am);

add(t);
add(cancel);

css.addItemListener(this);
b.addActionListener(this);
si.addItemListener (this);
sr.addItemListener (this);


}
public void actionPerformed(ActionEvent ae)
{

if(b.getActionCommand().equals("SUBMIT"))
{
d=Integer.parseInt(nr.getText());
s=(Integer.parseInt(sts.getText()))-d;

if(css.getSelectedItem().equals("A.C SLEEPER"))
{
am.setText("400");
}
else if(css.getSelectedItem().equals("FIRST CLASS"))
{
am.setText("250");
}
else
{
am.setText("100");
}

}


c=((Integer.parseInt(am.getText()))*(Integer.parseInt(nr.getText())));
t.setText("NAME:"+na.getText()+"
"+"After reservation total no.of
seats are:"
+s+"
"+"Train name
:"+g.getSelectedCheckbox().getLabel()+"
"+"Class:"+
css.getSelectedItem()+ "Total number of Rs :"+c);

if(cancel.getActionCommand().equals("CANCEL"))
{
repaint();
}

}

public void itemStateChanged(ItemEvent ie)
{

}

}

import java.io.*;
import java.awt.*;
import java.awt.Color.*;
import java.awt.event.*;
import java.applet.*;


/**/


public class train2 extends Applet implements
ActionListener,ItemListener

{
Label name,amount,seats,number;
TextField na,am,sts,nr;
TextArea t;
Choice css;

Checkbox si,sr;
CheckboxGroup g;

Button b,cancel;
int s,c,d;
int n1=400;
int n2=250;
int n3=100;

public void init()
{
setBackground(Color.yellow);
setForeground(Color.red);
setLayout(new FlowLayout());

na=new TextField(20);
am=new TextField(20);
sts=new TextField(20);
nr=new TextField(20);


name=new Label("NAME");
amount=new Label("AMOUNT");
seats=new Label("SEATS");
number=new Label("REQUIRED NO OF SEATS");

css=new Choice();
css.add("A.C SLEEPER");
css.add("FIRST CLASS");
css.add("SECOND CLASS");

t=new TextArea(40,45);

g=new CheckboxGroup();
si=new Checkbox("SATAPTI",g,false);
sr=new Checkbox("SABARI",g,false);

b=new Button("SUBMIT");
cancel=new Button("CANCEL");

add(name);
add(na);

add(seats);
add(sts);

add(number);
add(nr);


add(si);
add(sr);

add(css);

add(b);

add(amount);
add(am);

add(t);
add(cancel);

css.addItemListener(this);
b.addActionListener(this);
si.addItemListener (this);
sr.addItemListener (this);


}
public void actionPerformed(ActionEvent ae)
{

if(b.getActionCommand().equals("SUBMIT"))
{
d=Integer.parseInt(nr.getText());
s=(Integer.parseInt(sts.getText()))-d;

if(css.getSelectedItem().equals("A.C SLEEPER"))
{
am.setText("400");
}
else if(css.getSelectedItem().equals("FIRST CLASS"))
{
am.setText("250");
}
else
{
am.setText("100");
}

}


c=((Integer.parseInt(am.getText()))*(Integer.parseInt(nr.getText())));
t.setText("NAME:"+na.getText()+"
"+"After reservation total no.of
seats are:"
+s+"
"+"Train name
:"+g.getSelectedCheckbox().getLabel()+"
"+"Class:"+
css.getSelectedItem()+ "Total number of Rs :"+c);

if(cancel.getActionCommand().equals("CANCEL"))
{
repaint();
}

}

public void itemStateChanged(ItemEvent ie)
{

}

}

No comments:

Project Source Codes