can anyone help me correct and make my payslip work......how can I correct line 303,306 and 309..................
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class payslip3 extends JFrame implements ActionListener
{
private static int width=600;
private static int height=300;
private JLabel[] labelJL = new JLabel[18];
private JTextField[] textJT = new JTextField[16];
private JButton[] AddClearExit = new JButton[5];
private JPanel panel = new JPanel(new GridLayout());
public payslip3()
{
Container pane = getContentPane();
pane.setBackground (Color.black);
setTitle("USING BUTTON EVENT");
setSize(width,height);
labelJL[0] = new JLabel("Payslip",0);
labelJL[0].setForeground(Color.white);
labelJL[0].setFont(new Font("Comic Sans MS",Font.BOLD,50));
labelJL[0].setLocation(560,10);
labelJL[0].setSize(225,125);
pane.add(labelJL[0]);
labelJL[0] = new JLabel("RUN DATE:",0);
labelJL[0].setForeground(Color.white);
labelJL[0].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[0].setLocation(250,150);
labelJL[0].setSize(100,20);
pane.add(labelJL[0]);
textJT[0] = new JTextField();
textJT[0].setBackground(Color.white);
textJT[0].setLocation(350,150);
textJT[0].setSize(200,20);
pane.add(textJT[0]);
labelJL[1] = new JLabel("DAYS WORKED:",0);
labelJL[1].setForeground(Color.white);
labelJL[1].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[1].setLocation(200,200);
labelJL[1].setSize(150,20);
pane.add(labelJL[1]);
textJT[1] = new JTextField();
textJT[1].setBackground(Color.white);
textJT[1].setLocation(350,200);
textJT[1].setSize(200,20);
pane.add(textJT[1]);
labelJL[2] = new JLabel("BASIC PAY:",0);
labelJL[2].setForeground(Color.white);
labelJL[2].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[2].setLocation(225,250);
labelJL[2].setSize(100,20);
pane.add(labelJL[2]);
textJT[2] = new JTextField();
textJT[2].setBackground(Color.white);
textJT[2].setLocation(350,250);
textJT[2].setSize(200,20);
pane.add(textJT[2]);
labelJL[3] = new JLabel("OVERTIME WORKED:",0);
labelJL[3].setForeground(Color.white);
labelJL[3].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[3].setLocation(180,300);
labelJL[3].setSize(170,20);
pane.add(labelJL[3]);
textJT[3] = new JTextField();
textJT[3].setBackground(Color.white);
textJT[3].setLocation(350,300);
textJT[3].setSize(200,20);
pane.add(textJT[3]);
labelJL[4] = new JLabel("OVERTIME RATE:",0);
labelJL[4].setForeground(Color.white);
labelJL[4].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[4].setLocation(180,350);
labelJL[4].setSize(200,20);
pane.add(labelJL[4]);
textJT[4] = new JTextField();
textJT[4].setBackground(Color.white);
textJT[4].setLocation(350,350);
textJT[4].setSize(200,20);
pane.add(textJT[4]);
labelJL[5] = new JLabel("GROSS PAY:",0);
labelJL[5].setForeground(Color.white);
labelJL[5].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[5].setLocation(250,450);
labelJL[5].setSize(100,20);
pane.add(labelJL[5]);
textJT[5] = new JTextField();
textJT[5].setBackground(Color.white);
textJT[5].setLocation(350,450);
textJT[5].setSize(200,20);
pane.add(textJT[5]);
labelJL[6] = new JLabel("NET PAY:",0);
labelJL[6].setForeground(Color.white);
labelJL[6].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[6].setLocation(250,500);
labelJL[6].setSize(100,20);
pane.add(labelJL[6]);
textJT[6] = new JTextField();
textJT[6].setBackground(Color.white);
textJT[6].setLocation(350,500);
textJT[6].setSize(200,20);
pane.add(textJT[6]);
labelJL[7] = new JLabel("CUT-OFF DATE:",0);
labelJL[7].setForeground(Color.white);
labelJL[7].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[7].setLocation(680,150);
labelJL[7].setSize(210,20);
pane.add(labelJL[7]);
textJT[7] = new JTextField();
textJT[7].setBackground(Color.white);
textJT[7].setLocation(850,150);
textJT[7].setSize(200,20);
pane.add(textJT[7]);
labelJL[8] = new JLabel("NAME:",0);
labelJL[8].setForeground(Color.white);
labelJL[8].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[8].setLocation(750,190);
labelJL[8].setSize(100,20);
pane.add(labelJL[8]);
textJT[8] = new JTextField();
textJT[8].setBackground(Color.white);
textJT[8].setLocation(850,190);
textJT[8].setSize(200,20);
pane.add(textJT[8]);
labelJL[9] = new JLabel("TAX WITH HELD:",0);
labelJL[9].setForeground(Color.white);
labelJL[9].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[9].setLocation(680,300);
labelJL[9].setSize(200,20);
pane.add(labelJL[9]);
textJT[9] = new JTextField();
textJT[9].setBackground(Color.white);
textJT[9].setLocation(850,300);
textJT[9].setSize(200,20);
pane.add(textJT[9]);
labelJL[10] = new JLabel("SSS:",0);
labelJL[10].setForeground(Color.white);
labelJL[10].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[10].setLocation(760,350);
labelJL[10].setSize(100,20);
pane.add(labelJL[10]);
textJT[10] = new JTextField();
textJT[10].setBackground(Color.white);
textJT[10].setLocation(850,350);
textJT[10].setSize(200,20);
pane.add(textJT[10]);
labelJL[11] = new JLabel("MEDICAL:",0);
labelJL[11].setForeground(Color.white);
labelJL[11].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[11].setLocation(750,400);
labelJL[11].setSize(100,20);
pane.add(labelJL[11]);
textJT[11] = new JTextField();
textJT[11].setBackground(Color.white);
textJT[11].setLocation(850,400);
textJT[11].setSize(200,20);
pane.add(textJT[11]);
labelJL[12] = new JLabel("PAG-IBIG:",0);
labelJL[12].setForeground(Color.white);
labelJL[12].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[12].setLocation(750,450);
labelJL[12].setSize(100,20);
pane.add(labelJL[12]);
textJT[12] = new JTextField();
textJT[12].setBackground(Color.white);
textJT[12].setLocation(850,450);
textJT[12].setSize(200,20);
pane.add(textJT[12]);
labelJL[13] = new JLabel("SSS LOAN:",0);
labelJL[13].setForeground(Color.white);
labelJL[13].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[13].setLocation(750,500);
labelJL[13].setSize(100,20);
pane.add(labelJL[13]);
textJT[13] = new JTextField();
textJT[13].setBackground(Color.white);
textJT[13].setLocation(850,500);
textJT[13].setSize(200,20);
pane.add(textJT[13]);
labelJL[14] = new JLabel("PAG-IBIG LOAN:",0);
labelJL[14].setForeground(Color.white);
labelJL[14].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[14].setLocation(690,550);
labelJL[14].setSize(200,20);
pane.add(labelJL[14]);
textJT[14] = new JTextField();
textJT[14].setBackground(Color.white);
textJT[14].setLocation(850,550);
textJT[14].setSize(200,20);
pane.add(textJT[14]);
labelJL[15] = new JLabel("TOTAL DEDUCTION:",0);
labelJL[15].setForeground(Color.white);
labelJL[15].setFont(new Font("Verdana",Font.BOLD,13));
labelJL[15].setLocation(675,620);
labelJL[15].setSize(200,20);
pane.add(labelJL[15]);
textJT[15] = new JTextField();
textJT[15].setBackground(Color.white);
textJT[15].setLocation(850,620);
textJT[15].setSize(200,20);
pane.add(textJT[15]);
labelJL[16] = new JLabel("DEDUCTION",0);
labelJL[16].setForeground(Color.white);
labelJL[16].setFont(new Font("Gill Sans Ultra Bold",Font.BOLD,10));
labelJL[16].setLocation(870,250);
labelJL[16].setSize(100,20);
pane.add(labelJL[16]);
AddClearExit[0] = new JButton("Gross Pay");
AddClearExit[0].setLocation(225,750);
AddClearExit[0].setSize(150,20);
AddClearExit[0].addActionListener(this);
pane.add(AddClearExit[0]);
AddClearExit[0] = new JButton("Net Pay");
AddClearExit[0].setLocation(825,750);
AddClearExit[0].setSize(150,20);
AddClearExit[0].addActionListener(this);
pane.add(AddClearExit[0]);
AddClearExit[0] = new JButton("Total Deduction");
AddClearExit[0].setLocation(1025,750);
AddClearExit[0].setSize(200,20);
AddClearExit[0].addActionListener(this);
pane.add(AddClearExit[0]);
AddClearExit[1] = new JButton("Clear");
AddClearExit[1].setLocation(425,750);
AddClearExit[1]. setSize(150,20);
AddClearExit[1].addActionListener(this);
pane.add(AddClearExit[1]);
AddClearExit[2] = new JButton("Exit");
AddClearExit[2].setLocation(625,750);
AddClearExit[2].setSize(150,20);
AddClearExit[2].addActionListener(this);
pane.add(AddClearExit[2]);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent ae)
{
String temp = "";
long bp=0,otr=0,gp=0,d=0,tw=0, sss=0,m=0,p=0,sssl=0, pl=0,td=0;
try
{
bp=Long.parseLong(textJT[2].getText());
otr=Long.parseLong(textJT[4].getText());
gp=Long.parseLong(textJT[15].getText());
d=Long.parseLong(textJT[7].getText());
tw=Long.parseLong(textJT[8].getText());
sss=Long.parseLong(textJT[9].getText());
m=Long.parseLong(textJT[10].getText());
p=Long.parseLong(textJT[11].getText());
sssl=Long.parseLong(textJT[12].getText());
pl=Long.parseLong(textJT[13].getText());
td=Long.parseLong(textJT[14].getText());
}
catch (Exception ne)
{
for(int x=0;x<16;textJT[x].setText(temp),x++);
}
if(ae.getActionCommand().equals("Gross Pay"))
//this one {temp+=gp(bp*otr);
textJT[5].setText(temp);}
else if(ae.getActionCommand().equals("Net Pay"))
//this one {temp+=nt(gp-td);
textJT[6].setText(temp);}
else if(ae.getActionCommand().equals("Total Deduction"))
// and this one {temp+=td(tw+sss+m+p+sssl+pl);
textJT[15].setText(temp);}
if(ae.getActionCommand().equals("Clear"))
for(int x=0;x<16;textJT[x].setText(temp),x++);
if(ae.getActionCommand().equals("Exit"))
dispose();
}
public long gp(long x,long y)
{
return x*y;
}
public long nt(long x,long y)
{
return x-y;
}
public long td(long x,long y)
{
return x+y;
}
public static void main (String args[])
{
new Button();
}
}