com.twigasoft.settings.ClockInOut.java Source code

Java tutorial

Introduction

Here is the source code for com.twigasoft.settings.ClockInOut.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.twigasoft.settings;

import com.twigasoft.main.MainApp;
import com.twigasoft.utils.Database;
import java.awt.Component;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JScrollBar;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.joda.time.DateTime;
import org.joda.time.Period;

/**
 *
 * @author Victor
 */
public class ClockInOut extends javax.swing.JDialog {

    /**
     * Creates new form ClockInOut
     */
    MainApp app;
    DefaultListModel model;

    public ClockInOut(MainApp app, boolean modal) {
        super(app, modal);
        this.app = app;
        model = new DefaultListModel() {
            @Override
            public void addElement(Object element) {
                super.addElement(element); //To change body of generated methods, choose Tools | Templates.  
                int lastIndex = model.getSize() - 1;
                if (lastIndex >= 0) {
                    jList2.ensureIndexIsVisible(lastIndex);
                }
            }
        };
        initComponents();

        jList2.setCellRenderer(new DefaultListCellRenderer() {
            @Override
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                    boolean cellHasFocus) {
                JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected,
                        cellHasFocus);
                if (value.toString().contains(",")) {
                    label.setIcon(new ImageIcon(getClass().getResource("/com/twigasoft/images/green.png")));
                } else {
                    label.setIcon(new ImageIcon(getClass().getResource("/com/twigasoft/images/red.png")));
                }
                return label;
            }
        });
        jList2.addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent e) {

            }
        });
        getClockingInstances();
        lblLoggedAs.setText("Logged in as " + app.getTellerName());
    }

    public void getClockingInstances() {
        model.removeAllElements();
        Connection conn = null;
        PreparedStatement pst = null;
        ResultSet rs = null;
        String sql = "SELECT type, status, create_time FROM tbl_clocking WHERE emp_id=? AND DATEDIFF(create_time, ? ) >=0;";

        try {
            conn = Database.getConnection();
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
            String date = sf.format(new Date().getTime());
            pst = conn.prepareStatement(sql);
            pst.setInt(1, app.getEmpId());
            pst.setString(2, date);
            rs = pst.executeQuery();
            while (rs.next()) {
                String type = rs.getString(1);
                String status = rs.getString(2);
                String stamp = rs.getString(3);
                Date mydate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse(stamp);
                String time = new SimpleDateFormat("HH:mm:ss").format(mydate);
                if (status.equals("in")) {
                    model.addElement(time + "    " + type + ",");

                } else {
                    model.addElement(time + "    " + type);
                }

                System.err.println();
            }
        } catch (ParseException | SQLException e) {
            e.printStackTrace();
        }
        try {
            finalize();
        } catch (Throwable ex) {
            Logger.getLogger(ClockInOut.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel() {
            @Override
            protected void paintComponent(Graphics grphcs) {
                super.paintComponent(grphcs);
                Graphics2D g2d = (Graphics2D) grphcs;
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                GradientPaint gp = new GradientPaint(0, 0, getBackground().brighter(), 0, getHeight(),
                        getBackground().darker());
                g2d.setPaint(gp);
                g2d.fillRect(0, 0, getWidth(), getHeight() / 2);

            }
        };
        jLabel3 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        btnExit = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        btnClockIn = new javax.swing.JButton();
        btnLunch = new javax.swing.JButton();
        btnClockOut = new javax.swing.JButton();
        btnTeaBreak = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList2 = new javax.swing.JList(model);
        lblLoggedAs = new javax.swing.JLabel();

        setMaximumSize(new java.awt.Dimension(328, 327));
        setMinimumSize(new java.awt.Dimension(328, 327));
        setResizable(false);

        jPanel2.setBackground(new java.awt.Color(1, 119, 164));

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("  Employee Clock In/Out");

        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(0, 0, 0).addComponent(jLabel3,
                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(0, 0, 0)));
        jPanel2Layout
                .setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel2Layout.createSequentialGroup().addGap(0, 0, 0).addComponent(jLabel3,
                                javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, 0)));

        btnExit.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnExit.setText("Exit");
        btnExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExitActionPerformed(evt);
            }
        });

        btnClockIn.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        btnClockIn.setText("Clock In");
        btnClockIn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnClockInActionPerformed(evt);
            }
        });

        btnLunch.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnLunch.setText("Lunch Break");
        btnLunch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLunchActionPerformed(evt);
            }
        });

        btnClockOut.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        btnClockOut.setText("Clock Out");
        btnClockOut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnClockOutActionPerformed(evt);
            }
        });

        btnTeaBreak.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnTeaBreak.setText("Tea Break");
        btnTeaBreak.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTeaBreakActionPerformed(evt);
            }
        });

        jList2.setSelectionBackground(new java.awt.Color(255, 255, 255));
        jList2.setSelectionForeground(new java.awt.Color(0, 0, 0));
        jScrollPane2.setViewportView(jList2);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(jPanel1Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                        jPanel1Layout.createSequentialGroup().addComponent(btnClockIn)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(btnClockOut))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(btnTeaBreak, javax.swing.GroupLayout.PREFERRED_SIZE, 121,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(36, 36, 36).addComponent(btnLunch,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)))
                        .addContainerGap())
                .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(btnClockOut, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(btnClockIn, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(btnLunch).addComponent(btnTeaBreak,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 23,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)));

        lblLoggedAs.setBackground(new java.awt.Color(0, 0, 0));
        lblLoggedAs.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblLoggedAs.setForeground(new java.awt.Color(255, 255, 255));
        lblLoggedAs.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblLoggedAs.setOpaque(true);

        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)
                                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(lblLoggedAs, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap())
                .addGroup(jPanel3Layout.createSequentialGroup().addGap(238, 238, 238)
                        .addComponent(btnExit, javax.swing.GroupLayout.PREFERRED_SIZE, 66,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                        .addComponent(lblLoggedAs, javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnExit, javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap()));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING,
                        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,
                        javax.swing.GroupLayout.PREFERRED_SIZE));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, 0)
                        .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, 0)));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnClockInActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClockInActionPerformed
        if (!checkClockInstance("Clocked In", "in") || checkClockInstance("Tea Break", "in")
                || checkClockInstance("Lunch Break", "in")) {
            clockIn();
            btnClockIn.setEnabled(false);
            btnLunch.setEnabled(true);
            btnTeaBreak.setEnabled(true);
            btnClockOut.setEnabled(true);
        } else {
            JOptionPane.showMessageDialog(this, "Already Clocked in", "Clocked In", 1);
            //            btnClockIn.setEnabled(false);
            //            btnLunch.setEnabled(true);
            //            btnTeaBreak.setEnabled(true);
            //            btnClockOut.setEnabled(true);
        }
        getClockingInstances();
    }//GEN-LAST:event_btnClockInActionPerformed

    private void btnClockOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClockOutActionPerformed
        if (checkClockInstance("Clocked In", "in")) {
            clockOut();
            clearClockIn("Clocked In");
            clearClockIn("Tea Break");
            clearClockIn("Lunch Break");
            btnClockIn.setEnabled(true);
            btnLunch.setEnabled(false);
            btnTeaBreak.setEnabled(false);
            btnClockOut.setEnabled(false);
        } else {
            JOptionPane.showMessageDialog(this, "You have NOT Clocked In!", "Clocked Out", 1);
            btnClockIn.setEnabled(true);
            btnLunch.setEnabled(false);
            btnTeaBreak.setEnabled(false);
            btnClockOut.setEnabled(false);
        }
        getClockingInstances();
    }//GEN-LAST:event_btnClockOutActionPerformed

    private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
        this.setVisible(false);
    }//GEN-LAST:event_btnExitActionPerformed

    private void btnTeaBreakActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTeaBreakActionPerformed
        if (checkClockInstance("Clocked In", "in")) {
            if (!checkClockInstance("Tea Break", "in")) {
                giveTeaBreak();
                btnClockIn.setEnabled(true);
                btnLunch.setEnabled(false);
                btnClockOut.setEnabled(false);
                btnTeaBreak.setEnabled(false);
            } else {
                btnTeaBreak.setEnabled(false);
                JOptionPane.showMessageDialog(this, "Already Given Tea Break!", "Tea Break", 1);
            }
        } else {
            JOptionPane.showMessageDialog(this, "You have NOT Clocked In!", "Clocked Out", 1);
            btnClockIn.setEnabled(true);
            btnLunch.setEnabled(false);
            btnTeaBreak.setEnabled(false);
            btnClockOut.setEnabled(false);
        }
        getClockingInstances();
    }//GEN-LAST:event_btnTeaBreakActionPerformed

    private void btnLunchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLunchActionPerformed
        if (checkClockInstance("Clocked In", "in")) {
            if (!checkClockInstance("Lunch Break", "in")) {
                giveLunchBreak();
                btnClockIn.setEnabled(true);
                btnLunch.setEnabled(false);
                btnClockOut.setEnabled(false);
                btnTeaBreak.setEnabled(false);

            } else {
                btnLunch.setEnabled(false);
                JOptionPane.showMessageDialog(this, "Already Given Lunch Break!", "Lunch Break", 1);
            }
        } else {
            JOptionPane.showMessageDialog(this, "You have NOT Clocked In!", "Clocked Out", 1);
            btnClockIn.setEnabled(true);
            btnLunch.setEnabled(false);
            btnTeaBreak.setEnabled(false);
            btnClockOut.setEnabled(false);
        }
        getClockingInstances();
    }//GEN-LAST:event_btnLunchActionPerformed

    public void giveTeaBreak() {
        Connection conn = null;
        PreparedStatement pst = null;
        String sql = "INSERT INTO tbl_clocking VALUES(?,?,?,?,?)";
        try {
            conn = Database.getConnection();
            pst = conn.prepareStatement(sql);
            pst.setInt(1, 0);
            pst.setString(2, "Tea Break");
            pst.setInt(3, app.getEmpId());
            pst.setObject(4, new Timestamp(new Date().getTime()));
            pst.setString(5, "in");
            pst.executeUpdate();
        } catch (SQLException ex) {
            System.err.println(ex.getMessage());
        } finally {
            try {
                pst.close();
                conn.close();
            } catch (SQLException ex) {
                Logger.getLogger(ClockInOut.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    }

    public void giveLunchBreak() {
        Connection conn = null;
        PreparedStatement pst = null;
        String sql = "INSERT INTO tbl_clocking VALUES(?,?,?,?,?)";
        try {
            conn = Database.getConnection();
            pst = conn.prepareStatement(sql);
            pst.setInt(1, 0);
            pst.setString(2, "Lunch Break");
            pst.setInt(3, app.getEmpId());
            pst.setObject(4, new Timestamp(new Date().getTime()));
            pst.setString(5, "in");
            pst.executeUpdate();
        } catch (SQLException ex) {
            System.err.println(ex.getMessage());
        } finally {
            try {
                pst.close();
                conn.close();
            } catch (SQLException ex) {
                Logger.getLogger(ClockInOut.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    public void clockIn() {
        Connection conn = null;
        PreparedStatement pst = null;
        String sql = "INSERT INTO tbl_clocking VALUES(?,?,?,?,?)";
        try {
            conn = Database.getConnection();
            pst = conn.prepareStatement(sql);
            pst.setInt(1, 0);
            pst.setString(2, "Clocked In");
            pst.setInt(3, app.getEmpId());
            pst.setObject(4, new Timestamp(new Date().getTime()));
            pst.setString(5, "in");
            pst.executeUpdate();
        } catch (SQLException ex) {
            System.err.println(ex.getMessage());
        } finally {
            try {
                pst.close();
                conn.close();
            } catch (SQLException ex) {
                Logger.getLogger(ClockInOut.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    }

    public void clockOut() {
        Connection conn = null;
        PreparedStatement pst = null;
        String sql = "INSERT INTO tbl_clocking VALUES(?,?,?,?,?)";
        try {
            conn = Database.getConnection();
            pst = conn.prepareStatement(sql);
            pst.setInt(1, 0);
            pst.setString(2, "Clocked Out");
            pst.setInt(3, app.getEmpId());
            pst.setObject(4, new Timestamp(new Date().getTime()));
            pst.setString(5, "OUT");
            pst.executeUpdate();
        } catch (SQLException ex) {
            System.err.println(ex.getMessage());
        } finally {
            try {
                pst.close();
                conn.close();
            } catch (SQLException ex) {
                Logger.getLogger(ClockInOut.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    public boolean checkClockInstance(String type, String status) {
        Connection conn = null;
        PreparedStatement pst = null;
        ResultSet rs = null;
        String sql = "SELECT create_time FROM tbl_clocking WHERE emp_id=? AND type=? AND status=?";
        Timestamp stamp = null;
        try {
            conn = Database.getConnection();
            pst = conn.prepareStatement(sql);
            pst.setInt(1, app.getEmpId());
            pst.setString(2, type);
            pst.setString(3, status);
            rs = pst.executeQuery();
            while (rs.next()) {
                stamp = rs.getTimestamp(1);
                DateTime timestamp = new DateTime(new Date(stamp.getTime()));
                DateTime now = new DateTime(new Date().getTime());
                Period period = new Period(timestamp, now);
                if (period.getDays() == 0) {
                    return true;
                }
            }

        } catch (SQLException ex) {
            ex.printStackTrace();
        } finally {
            try {
                rs.close();
                pst.close();
                conn.close();

            } catch (SQLException ex) {
                Logger.getLogger(ClockInOut.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        return false;
    }

    public void clearClockIn(String type) {
        Connection conn = null;
        PreparedStatement pst = null;
        String sql = "UPDATE tbl_clocking SET  status= ? WHERE emp_id = ? AND status= ? AND type=?";
        try {
            conn = Database.getConnection();
            pst = conn.prepareStatement(sql);
            pst.setString(1, "OUT");
            pst.setInt(2, app.getEmpId());
            pst.setString(3, "in");
            pst.setString(4, type);
            pst.executeUpdate();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        try {
            finalize();
        } catch (Throwable ex) {
            Logger.getLogger(ClockInOut.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    /**
     * @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(ClockInOut.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ClockInOut.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ClockInOut.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ClockInOut.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                ClockInOut dialog = new ClockInOut(new MainApp(1), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnClockIn;
    private javax.swing.JButton btnClockOut;
    private javax.swing.JButton btnExit;
    private javax.swing.JButton btnLunch;
    private javax.swing.JButton btnTeaBreak;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JList jList2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lblLoggedAs;
    // End of variables declaration//GEN-END:variables
}