SALARY CALCULATOR WINDOWS APPLICATION USING NETBEANS



salary_cal.java

package salary_cal;

import static com.sun.org.apache.xalan.internal.lib.ExsltDatetime.date;

import java.util.Date;

 

public class salary_cal1 extends javax.swing.JFrame {

 

    public salary_cal1() {

        initComponents();

        paysheetHeader();

 

    }

 

    private void paysheetHeader() {

 

        txtbill.setText("*****************************************************************" + "\n"

                + "\t" + "ABC Company Pvt(Ltd.)" + "\n"

                + "******************************************************************" + "\n"

        );

    }

 

  

    @SuppressWarnings("unchecked")

    // <editor-fold defaultstate="collapsed" desc="Generated Code">                         

    private void initComponents() {

 

        jTextField6 = new javax.swing.JTextField();

        jTextField8 = new javax.swing.JTextField();

        jTextField4 = new javax.swing.JTextField();

        jTextField7 = new javax.swing.JTextField();

        jPanel1 = new javax.swing.JPanel();

        jPanel2 = new javax.swing.JPanel();

        jLabel1 = new javax.swing.JLabel();

        jLabel2 = new javax.swing.JLabel();

        jLabel3 = new javax.swing.JLabel();

        jLabel4 = new javax.swing.JLabel();

        jLabel6 = new javax.swing.JLabel();

        jCheckBox1 = new javax.swing.JCheckBox();

        jTextField1 = new javax.swing.JTextField();

        txtsal = new javax.swing.JTextField();

        jPanel3 = new javax.swing.JPanel();

        jCheckBox2 = new javax.swing.JCheckBox();

        jLabel5 = new javax.swing.JLabel();

        jLabel11 = new javax.swing.JLabel();

        jLabel12 = new javax.swing.JLabel();

        txtwelfare = new javax.swing.JTextField();

        txtother = new javax.swing.JTextField();

        jLabel13 = new javax.swing.JLabel();

        txttotalD = new javax.swing.JLabel();

        txtdedication = new javax.swing.JLabel();

        txtepfamount = new javax.swing.JLabel();

        jPanel4 = new javax.swing.JPanel();

        jLabel10 = new javax.swing.JLabel();

        txtOT = new javax.swing.JTextField();

        jLabel9 = new javax.swing.JLabel();

        txtotherallow = new javax.swing.JTextField();

        jLabel7 = new javax.swing.JLabel();

        txtgross = new javax.swing.JLabel();

        jLabel17 = new javax.swing.JLabel();

        txtearning = new javax.swing.JTextField();

        jButton1 = new javax.swing.JButton();

        jButton2 = new javax.swing.JButton();

        jScrollPane1 = new javax.swing.JScrollPane();

        txtbill = new javax.swing.JTextArea();

        jButton3 = new javax.swing.JButton();

        jCheckBox3 = new javax.swing.JCheckBox();

        jLabel14 = new javax.swing.JLabel();

        jLabel15 = new javax.swing.JLabel();

        txtdesig = new javax.swing.JTextField();

        jLabel16 = new javax.swing.JLabel();

        txtetfamount = new javax.swing.JLabel();

        txtep = new javax.swing.JLabel();

        txtnet = new javax.swing.JLabel();

 

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

 

        jPanel1.setBackground(new java.awt.Color(204, 204, 204));

 

        jPanel2.setBackground(new java.awt.Color(204, 204, 255));

        jPanel2.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1), javax.swing.BorderFactory.createCompoundBorder()));

 

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N

        jLabel1.setText("Salary Calculator");

 

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);

        jPanel2.setLayout(jPanel2Layout);

        jPanel2Layout.setHorizontalGroup(

            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(jPanel2Layout.createSequentialGroup()

                .addGap(205, 205, 205)

                .addComponent(jLabel1)

                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

        );

        jPanel2Layout.setVerticalGroup(

            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(jPanel2Layout.createSequentialGroup()

                .addContainerGap()

                .addComponent(jLabel1)

                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

        );

 

        jLabel2.setText("Employee:");

 

        jLabel3.setText("Besic Salary:");

 

        jLabel4.setText("Net Salary:");

 

        jLabel6.setText(" ETF Employer:");

 

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Deduction", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

 

        jLabel5.setText("EPF Employee Amount:");

 

        jLabel11.setText("Welfare Contribution");

 

        jLabel12.setText("Other Constribution");

 

        jLabel13.setText("Total Deduction:");

 

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);

        jPanel3.setLayout(jPanel3Layout);

        jPanel3Layout.setHorizontalGroup(

            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(jPanel3Layout.createSequentialGroup()

                .addContainerGap()

                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

                    .addGroup(jPanel3Layout.createSequentialGroup()

                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addComponent(jLabel12)

                            .addComponent(jLabel13))

                        .addGap(47, 47, 47)

                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addGroup(jPanel3Layout.createSequentialGroup()

                                .addComponent(txtdedication)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                                .addComponent(txttotalD, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE))

                            .addComponent(txtother)))

                    .addGroup(jPanel3Layout.createSequentialGroup()

                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addGroup(jPanel3Layout.createSequentialGroup()

                                .addComponent(jCheckBox2)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

                                .addComponent(jLabel5))

                            .addComponent(jLabel11))

                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addGroup(jPanel3Layout.createSequentialGroup()

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

                                .addComponent(txtepfamount))

                            .addGroup(jPanel3Layout.createSequentialGroup()

                                .addGap(4, 4, 4)

                                .addComponent(txtwelfare, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)))))

                .addContainerGap(16, Short.MAX_VALUE))

        );

        jPanel3Layout.setVerticalGroup(

            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(jPanel3Layout.createSequentialGroup()

                .addGap(10, 10, 10)

                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                        .addComponent(jLabel5)

                        .addComponent(txtepfamount))

                    .addComponent(jCheckBox2))

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jLabel11)

                    .addComponent(txtwelfare, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

                .addGap(7, 7, 7)

                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jLabel12)

                    .addComponent(txtother, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

                .addGap(17, 17, 17)

                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jLabel13)

                    .addComponent(txttotalD, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(txtdedication))

                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

        );

 

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Earnings", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

 

        jLabel10.setText("OT");

 

        jLabel9.setText("Allowance");

 

        jLabel7.setText("Gross Salary:");

 

        jLabel17.setText("Other earnings");

 

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);

        jPanel4.setLayout(jPanel4Layout);

        jPanel4Layout.setHorizontalGroup(

            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(jPanel4Layout.createSequentialGroup()

                .addContainerGap()

                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()

                        .addComponent(jLabel7)

                        .addGap(18, 18, 18)

                        .addComponent(txtgross, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)

                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

                    .addGroup(jPanel4Layout.createSequentialGroup()

                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

                            .addGroup(jPanel4Layout.createSequentialGroup()

                                .addComponent(jLabel17)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

                                .addComponent(txtearning))

                            .addGroup(jPanel4Layout.createSequentialGroup()

                                .addComponent(jLabel10)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                                .addComponent(txtOT, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE))

                            .addGroup(jPanel4Layout.createSequentialGroup()

                                .addComponent(jLabel9)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                                .addComponent(txtotherallow, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)))

                        .addGap(29, 29, 29))))

        );

        jPanel4Layout.setVerticalGroup(

            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(jPanel4Layout.createSequentialGroup()

                .addContainerGap()

                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jLabel9)

                    .addComponent(txtotherallow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jLabel17)

                    .addComponent(txtearning, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(txtOT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jLabel10))

                .addGap(16, 16, 16)

                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jLabel7)

                    .addComponent(txtgross))

                .addContainerGap(14, Short.MAX_VALUE))

        );

 

        jButton1.setText("Cal");

        jButton1.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jButton1ActionPerformed(evt);

            }

        });

 

        jButton2.setText("Print");

        jButton2.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jButton2ActionPerformed(evt);

            }

        });

 

        txtbill.setColumns(20);

        txtbill.setRows(5);

        jScrollPane1.setViewportView(txtbill);

 

        jButton3.setText("Clear");

        jButton3.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jButton3ActionPerformed(evt);

            }

        });

 

        jLabel14.setText(" EPF Employer:");

 

        jLabel15.setText("Designation:");

 

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

        jPanel1.setLayout(jPanel1Layout);

        jPanel1Layout.setHorizontalGroup(

            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

            .addGroup(jPanel1Layout.createSequentialGroup()

                .addContainerGap()

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

                    .addGroup(jPanel1Layout.createSequentialGroup()

                        .addComponent(jLabel15)

                        .addGap(18, 18, 18)

                        .addComponent(txtdesig, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE))

                    .addGroup(jPanel1Layout.createSequentialGroup()

                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

                            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()

                                .addGap(58, 58, 58)

                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

                                .addComponent(jButton3)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                                .addComponent(jCheckBox3))

                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()

                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

                                    .addGroup(jPanel1Layout.createSequentialGroup()

                                        .addComponent(jLabel3)

                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                                        .addComponent(txtsal, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE))

                                    .addGroup(jPanel1Layout.createSequentialGroup()

                                        .addComponent(jLabel2)

                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)))

                                .addGap(35, 35, 35))

                            .addGroup(jPanel1Layout.createSequentialGroup()

                                .addGap(17, 17, 17)

                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

                                    .addComponent(jLabel4)

                                    .addComponent(jLabel16))

                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                                    .addGroup(jPanel1Layout.createSequentialGroup()

                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                                        .addComponent(jCheckBox1))

                                    .addGroup(jPanel1Layout.createSequentialGroup()

                                        .addGap(84, 84, 84)

                                        .addComponent(txtnet)))))

                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addGroup(jPanel1Layout.createSequentialGroup()

                                .addGap(32, 32, 32)

                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE))

                            .addGroup(jPanel1Layout.createSequentialGroup()

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                                    .addGroup(jPanel1Layout.createSequentialGroup()

                                        .addComponent(jLabel6)

                                        .addGap(27, 27, 27)

                                        .addComponent(txtetfamount))

                                    .addGroup(jPanel1Layout.createSequentialGroup()

                                        .addComponent(jLabel14)

                                        .addGap(28, 28, 28)

                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                                            .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)

                                            .addComponent(txtep))))))))

                .addContainerGap(47, Short.MAX_VALUE))

        );

        jPanel1Layout.setVerticalGroup(

            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(jPanel1Layout.createSequentialGroup()

                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                .addGap(18, 18, 18)

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                    .addComponent(jLabel2)

                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                        .addComponent(jLabel15)

                        .addComponent(txtdesig, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jLabel3)

                    .addComponent(txtsal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

                .addGap(18, 18, 18)

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

                    .addGroup(jPanel1Layout.createSequentialGroup()

                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                        .addGap(2, 2, 2)

                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                        .addGap(18, 18, 18)

                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                            .addComponent(jLabel4)

                            .addComponent(txtnet))

                        .addGap(4, 4, 4)

                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                            .addComponent(jCheckBox1)

                            .addComponent(jLabel16)))

                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()

                        .addComponent(jScrollPane1)

                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                            .addComponent(jLabel6)

                            .addComponent(txtetfamount))

                        .addGap(7, 7, 7)))

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                        .addComponent(jButton1)

                        .addComponent(jButton3))

                    .addGroup(jPanel1Layout.createSequentialGroup()

                        .addGap(4, 4, 4)

                        .addComponent(jCheckBox3))

                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                        .addComponent(jLabel14)

                        .addComponent(txtep)))

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                .addComponent(jButton2)

                .addContainerGap(26, Short.MAX_VALUE))

        );

 

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

        getContentPane().setLayout(layout);

        layout.setHorizontalGroup(

            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

        );

        layout.setVerticalGroup(

            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(layout.createSequentialGroup()

                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                .addGap(0, 28, Short.MAX_VALUE))

        );

 

        pack();

    }// </editor-fold>                       

    double empname, sal, etf, epf, etfamount, epfamount, gross, earning, netsal, ot, otherallow, wel, otherC, total, totalD, ep;

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        

 

        sal = Double.parseDouble(txtsal.getText());

        if (jCheckBox1.isSelected() == true) {

            etfamount = sal * 3 / 100;

        }

        if (jCheckBox2.isSelected() == true) {

            epfamount = sal * 8 / 100;

        }

        if (jCheckBox3.isSelected() == true) {

            ep = sal * 12 / 100;

        }

        txtep.setText(String.valueOf(ep));

        txtetfamount.setText(String.valueOf(etfamount));

        txtepfamount.setText(String.valueOf(epfamount));

        wel = Double.parseDouble(txtwelfare.getText());

        otherC = Double.parseDouble(txtother.getText());

        otherallow = Double.parseDouble(txtotherallow.getText());

        earning= Double.parseDouble(txtotherallow.getText());

        ot = Double.parseDouble(txtOT.getText());

        gross = sal + earning + otherallow + ot;

        txtgross.setText(String.valueOf(gross));

        totalD = epfamount + wel + otherC;

        txtdedication.setText(String.valueOf(totalD));

        total = gross - epfamount - wel - otherC;

        txtnet.setText(String.valueOf(total));

 

 

    }                                       

 

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         

        txtbill.setText(txtbill.getText() + "Employee Name:" + "  " + jTextField1.getText() + "\n");

        txtbill.setText(txtbill.getText() + "Designation:" + "   " + txtdesig.getText() + "\n");

        txtbill.setText(txtbill.getText() + "Net Income:" + txtnet.getText() + "\n");

        txtbill.setText(txtbill.getText() + "------------------------------------------------------------------------------" + "\n");

        txtbill.setText(txtbill.getText() + "Basic Salary:" + "\t" + "\t" + "\t" + txtsal.getText() + "\n");

        txtbill.setText(txtbill.getText() + "Earnings" + "\n");

        txtbill.setText(txtbill.getText() + "\t" + "Allowance:" + "\t" + "                              " + txtearning.getText() + "\n");

        txtbill.setText(txtbill.getText() + "\t" + "Other Allowance:" + "\t" + txtotherallow.getText() + "\n");

        txtbill.setText(txtbill.getText() + "\t" + "Over Time" + "\t" + "\t" + txtOT.getText() + "\n");

        txtbill.setText(txtbill.getText() + "\t" + "\t" + "                          " + "------------------" + "\n");

        txtbill.setText(txtbill.getText() + "Gross Salary" + "\t" + "\t" + "                               " + txtgross.getText() + "\n");

        txtbill.setText(txtbill.getText() + "Deductions" + "\n");

        txtbill.setText(txtbill.getText() + "\t" + "EPF Employee" + "     " + "8%" + "\t" + txtepfamount.getText() + "\n");

        txtbill.setText(txtbill.getText() + "\t" + "WelFare Constribution" + "\t" + txtwelfare.getText() + "\n");

        txtbill.setText(txtbill.getText() + "\t" + "Other Constribution" + "\t" + txtother.getText() + "\n");

        txtbill.setText(txtbill.getText() + "Total Deduction" + "\t" + "\t" + "\t" + txtdedication.getText() + "\n");

        txtbill.setText(txtbill.getText() + "\t" + "\t" + "                        " + "------------------" + "\n");

        txtbill.setText(txtbill.getText() + "Net Salary" + "\t" + "\t" + "\t" + txtnet.getText() + "\n");

        txtbill.setText(txtbill.getText() + "\t" + "\t" + "                       " + "------------------" + "\n");

        txtbill.setText(txtbill.getText() + "\t" + "\t" + "                       " + "------------------" + "\n" + "\n");

        txtbill.setText(txtbill.getText() + "\t" + "EPF Employee" + "     " + "12%" + "\t" + txtep.getText() + "\n");

        txtbill.setText(txtbill.getText() + "\t" + "ETF Employee" + "     " + "3%" + "\t" + txtetfamount.getText() + "\n");

 

 

    }                                       

 

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                        

        jTextField1.setText("");

        txtnet.setText("");

        txtsal.setText("");

        txtearning.setText("");

        txtotherallow.setText("");

        txtOT.setText("");

        txtgross.setText("");

        txtepfamount.setText("");

        txtwelfare.setText("");

        txtother.setText("");

        txtdedication.setText("");

        txtsal.setText("");

    }                                       

 

    /**

     * @param args the command line arguments

     */

    public static void main(String args[]) {

 

        /* Set the Nimbus look and feel */

        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">

        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.

         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

         */

        try {

            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {

                if ("Nimbus".equals(info.getName())) {

                    javax.swing.UIManager.setLookAndFeel(info.getClassName());

                    break;

                }

            }

        } catch (ClassNotFoundException ex) {

            java.util.logging.Logger.getLogger(salary_cal1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        } catch (InstantiationException ex) {

            java.util.logging.Logger.getLogger(salary_cal1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        } catch (IllegalAccessException ex) {

            java.util.logging.Logger.getLogger(salary_cal1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        } catch (javax.swing.UnsupportedLookAndFeelException ex) {

            java.util.logging.Logger.getLogger(salary_cal1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        }

        //</editor-fold>

        //</editor-fold>

 

        /* Create and display the form */

        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {

                new salary_cal1().setVisible(true);

            }

        });

    }

 

    // Variables declaration - do not modify                     

    private javax.swing.JButton jButton1;

    private javax.swing.JButton jButton2;

    private javax.swing.JButton jButton3;

    private javax.swing.JCheckBox jCheckBox1;

    private javax.swing.JCheckBox jCheckBox2;

    private javax.swing.JCheckBox jCheckBox3;

    private javax.swing.JLabel jLabel1;

    private javax.swing.JLabel jLabel10;

    private javax.swing.JLabel jLabel11;

    private javax.swing.JLabel jLabel12;

    private javax.swing.JLabel jLabel13;

    private javax.swing.JLabel jLabel14;

    private javax.swing.JLabel jLabel15;

    private javax.swing.JLabel jLabel16;

    private javax.swing.JLabel jLabel17;

    private javax.swing.JLabel jLabel2;

    private javax.swing.JLabel jLabel3;

    private javax.swing.JLabel jLabel4;

    private javax.swing.JLabel jLabel5;

    private javax.swing.JLabel jLabel6;

    private javax.swing.JLabel jLabel7;

    private javax.swing.JLabel jLabel9;

    private javax.swing.JPanel jPanel1;

    private javax.swing.JPanel jPanel2;

    private javax.swing.JPanel jPanel3;

    private javax.swing.JPanel jPanel4;

    private javax.swing.JScrollPane jScrollPane1;

    private javax.swing.JTextField jTextField1;

    private javax.swing.JTextField jTextField4;

    private javax.swing.JTextField jTextField6;

    private javax.swing.JTextField jTextField7;

    private javax.swing.JTextField jTextField8;

    private javax.swing.JTextField txtOT;

    private javax.swing.JTextArea txtbill;

    private javax.swing.JLabel txtdedication;

    private javax.swing.JTextField txtdesig;

    private javax.swing.JTextField txtearning;

    private javax.swing.JLabel txtep;

    private javax.swing.JLabel txtepfamount;

    private javax.swing.JLabel txtetfamount;

    private javax.swing.JLabel txtgross;

    private javax.swing.JLabel txtnet;

    private javax.swing.JTextField txtother;

    private javax.swing.JTextField txtotherallow;

    private javax.swing.JTextField txtsal;

    private javax.swing.JLabel txttotalD;

    private javax.swing.JTextField txtwelfare;

    // End of variables declaration                  

}


YouTube link: https://youtu.be/EqpGVhDQfH4

Comments

Popular posts from this blog

ELECTRON PROJECT LOGIN & SIGNUP FORM

STUDENT REGISTRATION WEB APPLICATION USING JAVA(NETBEANS) + MYSQL(PHPMYADMIN) - PART 01