javaapplication5.NewJFrame.java Source code

Java tutorial

Introduction

Here is the source code for javaapplication5.NewJFrame.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 javaapplication5;

import beans.Compensation;
import beans.Configuration;
import business.RegistroBO;
import utils.IconeNoTray;
import utils.Zipper;
import utils.Constants;
import persist.ControlSerialize;
import dao.RegistroDao;
import dao.ConfigurationDao;
import java.awt.AWTException;
import java.io.File;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JSpinner;
import org.joda.time.LocalDate;
import org.joda.time.LocalTime;

/**
 *
 * @author S018248
 */
public class NewJFrame extends javax.swing.JFrame {

    private final int MANHA_H_DEFAULT = 8;
    private final int MANHA_M_DEFAULT = 0;
    private final int ALMOCO_H_DEFAULT = 12;
    private final int ALMOCO_M_DEFAULT = 0;
    private final int ALMOCO2_H_DEFAULT = 13;
    private final int ALMOCO2_M_DEFAULT = 30;
    private final int TARDE_H_DEFAULT = 17;
    private final int TARDE_M_DEFAULT = 30;

    private final ExibeLembrete exibeLembreteThread;
    private final IconeNoTray trayManager;
    private RegistroDao registroDao;
    private ConfigurationDao configurationDao;
    private RegistroBO registroBO;

    //localtimes
    private LocalTime manhaObj;
    private LocalTime almocoObj;
    private LocalTime almoco2Obj;
    private LocalTime tardeObj;
    private LocalTime hPretendidaObj;

    /**
     * Creates new form NewJFrame
     */
    public NewJFrame() throws Exception {
        instancePrivateObjects();
        this.setIconImage(new ImageIcon(getClass().getResource("/img/icon64.png")).getImage());
        trayManager = new IconeNoTray(this, new ImageIcon(getClass().getResource("/img/icon.png")));
        exibeLembreteThread = new ExibeLembrete(trayManager, configurationDao.getConfiguration());
        exibeLembreteThread.start();

        initComponents();

        configComponents();

        calc();

        lateTime.setText(registroBO.getLateTimeByMonth(new Date()).toString("HH:mm"));

        loadCompensation(configurationDao.getConfiguration().getCompensation());

    }

    //static methods
    public static int convertToMinutes2(float m) {
        int minutes = (int) Math.round(m * 60);
        return minutes;
    }

    public static int round(float d, int decimalPlace) {
        BigDecimal bd = new BigDecimal(Float.toString(d));
        bd = bd.setScale(decimalPlace, BigDecimal.ROUND_UP);
        return bd.intValue();
    }

    public static LocalTime decreaseTime(LocalTime time, int h, int m) {
        time = time.minusHours(h);
        time = time.minusMinutes(m);
        return time;
    }

    public static LocalTime increaseTime(LocalTime time, int h, int m) {
        time = time.plusHours(h);
        time = time.plusMinutes(m);
        return time;
    }

    //protected methods
    protected void loadRegistry(Registro reg) {

        setSpinValue(manhaH, manhaM, reg.getManha());
        setSpinValue(almocoH, almocoM, reg.getAlmoco());
        setSpinValue(almoco2H, almoco2M, reg.getAlmoco2());
        setSpinValue(tardeH, tardeM, reg.getTarde());
        setSpinValue(hPretendidasH, hPretendidasM, reg.gethPretendida());

    }

    protected void editRegistry(Registro reg) {
        //enable fields for edit
        dataAtual.setEditable(true);
        btCalc.setVisible(false);
        btSave.setVisible(true);
        btLoadLast.setEnabled(false);
        btShowHistory.setEnabled(false);

        dataAtual.setText(new SimpleDateFormat("dd/MM/yyyy").format(reg.getDate()));
        loadRegistry(reg);
    }

    //private methods
    private void instancePrivateObjects() {
        manhaObj = new LocalTime(0, 0);
        almocoObj = new LocalTime(0, 0);
        almoco2Obj = new LocalTime(0, 0);
        tardeObj = new LocalTime(0, 0);
        hPretendidaObj = new LocalTime(0, 0);
        registroDao = new RegistroDao();
        configurationDao = new ConfigurationDao();
        registroBO = new RegistroBO(registroDao);
    }

    private void backup() {
        try {
            File backupFolder = new File(ControlSerialize.BACKUP_FOLDER);
            if (backupFolder.exists() && backupFolder.listFiles().length > 0) {
                File files[] = backupFolder.listFiles();
                Calendar cal = Calendar.getInstance();
                JFileChooser jfc = new JFileChooser();
                jfc.setSelectedFile(new File("backup" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH)
                        + cal.get(Calendar.DAY_OF_MONTH) + ".zip"));
                if (jfc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
                    if (jfc.getSelectedFile() != null) {

                        new Zipper().criarZip(jfc.getSelectedFile(), files);
                        JOptionPane.showMessageDialog(null, "Backup realizado!");
                    }
                }
            } else {
                JOptionPane.showMessageDialog(null, "No h registros para realizar backup!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, "Erro:backup");
        }
    }

    private void restoreBackup() {
        try {
            JFileChooser jfc = new JFileChooser();
            if (jfc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
                File selectedFile = jfc.getSelectedFile();
                if (selectedFile != null) {
                    String selectedExtension = selectedFile.getName().substring(
                            selectedFile.getName().lastIndexOf(".") + 1, selectedFile.getName().length());
                    if (selectedExtension.equals(ControlSerialize.BACKUP_FILE_EXTENSION)) {
                        new Zipper().extrairZip(selectedFile, new File(ControlSerialize.BACKUP_FOLDER));
                        JOptionPane.showMessageDialog(null, "Backup restaurado!");
                    }
                    File files[] = jfc.getSelectedFile().getParentFile().listFiles();
                    if (files != null) {
                        for (File f : files) {
                            String filename = f.getName();
                            String extension = filename.substring(filename.lastIndexOf(".") + 1, filename.length());
                            if (extension.equals(RegistroDao.FILE_EXTENSION)) {
                                File backupFolder = new File(ControlSerialize.BACKUP_FOLDER);
                                if (!backupFolder.exists()) {
                                    backupFolder.mkdir();
                                }
                                ControlSerialize.copyFile(f, new File(ControlSerialize.BACKUP_FOLDER + filename));
                            } else {
                                //                        JOptionPane.showMessageDialog(null, "Arquivo invlido!");
                            }
                        }
                        JOptionPane.showMessageDialog(null, "Backup restaurado!");
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, "Erro:restoreBackup");
        }
    }

    private void loadLastRegistry() {
        List<Registro> list = registroDao.getListByMonth(new Date());
        if (list == null || list.isEmpty()) {
            JOptionPane.showMessageDialog(null, "Nenhum registro encontrado este deste ms");
        } else {
            loadRegistry(list.get(list.size() - 1));
        }

    }

    private void setTime() {
        try {
            for (int i = 0; i < 59; i++) {
                if (calc().compareTo(getHPretendida()) < 0) {
                    if (!isManhaFix.isSelected()) {
                        setSpinValue(manhaH, manhaM, decreaseTime(getManha(), 0, 1));
                    } else {
                        break;
                    }
                } else {
                    break;
                }
            }
            for (int i = 0; i < 59; i++) {
                if (calc().compareTo(getHPretendida()) < 0) {
                    LocalTime almoco = getAlmoco();
                    LocalTime tmp = decreaseTime(getAlmoco2(), almoco.getHourOfDay(), almoco.getMinuteOfHour());
                    if (!isAlmocoFix.isSelected() && (tmp.getHourOfDay() >= 1)) {
                        setSpinValue(almocoH, almocoM, increaseTime(getAlmoco(), 0, 1));
                    } else {
                        break;
                    }
                } else if (calc().compareTo(getHPretendida()) > 0) {
                    if (!isAlmocoFix.isSelected() && ((getAlmoco().getHourOfDay() >= Constants.ALMOCO_LIMIT
                            .getHourOfDay())
                            && (getAlmoco().getMinuteOfHour() > Constants.ALMOCO_LIMIT.getMinuteOfHour()))) {
                        setSpinValue(almocoH, almocoM, decreaseTime(getAlmoco(), 0, 1));
                    } else {
                        break;
                    }
                }
            }
            for (int i = 0; i < 59; i++) {
                if (calc().compareTo(getHPretendida()) < 0) {
                    LocalTime almoco = getAlmoco();
                    LocalTime tmp = decreaseTime(getAlmoco2(), almoco.getHourOfDay(), almoco.getMinuteOfHour());
                    if (!isAlmoco2Fix.isSelected() && (tmp.getHourOfDay() >= 1)) {
                        setSpinValue(almoco2H, almoco2M, decreaseTime(getAlmoco2(), 0, 1));
                    } else {
                        break;
                    }
                } else {
                    break;
                }
            }
            for (int i = 0; i < 59; i++) {
                if (calc().compareTo(getHPretendida()) < 0) {
                    if (!isTardeFix.isSelected()) {
                        setSpinValue(tardeH, tardeM, increaseTime(getTarde(), 0, 1));
                    } else {
                        break;
                    }
                } else if ((calc().compareTo(getHPretendida()) > 0)
                        && ((getTarde().getHourOfDay() >= 17) && (getTarde().getMinuteOfHour() >= 0))) {
                    if (!isTardeFix.isSelected()) {
                        setSpinValue(tardeH, tardeM, decreaseTime(getTarde(), 0, 1));
                    } else {
                        break;
                    }
                } else {
                    break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, "Erro:setTime");
        }
    }

    private void setSpinValue(JSpinner h, JSpinner m, LocalTime value) {
        h.setValue(value.getHourOfDay());
        m.setValue(value.getMinuteOfHour());
    }

    private LocalTime calc() {
        LocalTime res = new LocalTime(8, 0);
        try {
            res = getTotal();
            result.setText(getTotal().toString("HH:mm") + " hrs trabalhadas");

            exibeLembreteThread.setTimes(new LocalTime[] { getManha(), getAlmoco(), getAlmoco2(), getTarde() });
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, "Erro:calc");
        }
        return res;
    }

    private void btSaveAction() {

        boolean res = registroDao.edit(fillObjectFromFields());
        if (res) {
            JOptionPane.showMessageDialog(null, "Editado com sucesso!");
        } else {
            JOptionPane.showMessageDialog(null, "Erro:btSaveAction");
        }
        //disable fields for edit
        dataAtual.setEditable(false);
        btCalc.setVisible(true);
        btSave.setVisible(false);
        btLoadLast.setEnabled(true);
        btShowHistory.setEnabled(true);
        loadLastRegistry();
        dataAtual.setText(new SimpleDateFormat("dd/MM/yyyy").format(new Date()));
    }

    private void configComponents() {
        hPretendidasH.setModel(new javax.swing.SpinnerNumberModel(8, 0, 23, 1));
        hPretendidasM.setModel(new javax.swing.SpinnerNumberModel(0, 0, 59, 1));

        manhaH.setModel(new javax.swing.SpinnerNumberModel(MANHA_H_DEFAULT, 0, 23, 1));
        manhaM.setModel(new javax.swing.SpinnerNumberModel(MANHA_M_DEFAULT, 0, 59, 1));

        almocoH.setModel(new javax.swing.SpinnerNumberModel(ALMOCO_H_DEFAULT, 0, 23, 1));
        almocoM.setModel(new javax.swing.SpinnerNumberModel(ALMOCO_M_DEFAULT, 0, 59, 1));

        almoco2H.setModel(new javax.swing.SpinnerNumberModel(ALMOCO2_H_DEFAULT, 0, 23, 1));
        almoco2M.setModel(new javax.swing.SpinnerNumberModel(ALMOCO2_M_DEFAULT, 0, 59, 1));

        tardeH.setModel(new javax.swing.SpinnerNumberModel(TARDE_H_DEFAULT, 0, 23, 1));
        tardeM.setModel(new javax.swing.SpinnerNumberModel(TARDE_M_DEFAULT, 0, 59, 1));

        dataAtual.setText(new SimpleDateFormat("dd/MM/yyyy").format(new Date()));
        dtBeginCompensation.setText(new SimpleDateFormat("dd/MM/yyyy").format(new Date()));
        dtEndCompensation.setText(new SimpleDateFormat("dd/MM/yyyy").format(new Date()));
        resultCompensation.setText("00:00 horas");

        btSave.setVisible(false);
    }

    private void addRegToHistory() {
        try {
            registroDao.add(fillObjectFromFields());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private Registro fillObjectFromFields() {
        Registro reg = new Registro();
        try {
            reg.setDate(new SimpleDateFormat("dd/MM/yyyy").parse(dataAtual.getText()));
            reg.setManha(getManha());
            reg.setAlmoco(getAlmoco());
            reg.setAlmoco2(getAlmoco2());
            reg.setTarde(getTarde());
            reg.sethPretendida(getHPretendida());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return reg;
    }

    private void calcCompensation() {
        try {
            if (cbCompensation.isSelected() && validateDateCompensation()) {
                Date beginDt, endDate;
                beginDt = new SimpleDateFormat("dd/MM/yyyy").parse(dtBeginCompensation.getText().trim());
                endDate = new SimpleDateFormat("dd/MM/yyyy").parse(dtEndCompensation.getText().trim());
                LocalTime overTime = registroBO.getOvertime(beginDt, endDate);

                resultCompensation.setText(overTime.toString("HH:mm") + " hrs compensadas");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private boolean validateDateCompensation() {
        boolean result = true;
        try {
            //campos text no podem estar vazios
            if ((dtBeginCompensation.getText().trim().length() < 0)
                    || (dtEndCompensation.getText().trim().length() < 0)) {
                result = false;
            }
            //validar datas
            if (result) {
                //captura datas
                Date beginDt = null, endDate = null;
                try {
                    beginDt = new SimpleDateFormat("dd/MM/yyyy").parse(dtBeginCompensation.getText().trim());
                    endDate = new SimpleDateFormat("dd/MM/yyyy").parse(dtEndCompensation.getText().trim());
                } catch (Exception e) {
                    result = false;
                }
                if (result) {
                    //mximo dois anos de intervalo
                    int yearsQtty = LocalDate.fromDateFields(endDate).getYear()
                            - LocalDate.fromDateFields(beginDt).getYear();
                    if (yearsQtty < 0 || yearsQtty > 2) {
                        result = false;
                    }
                }
                //segunda data no pode ser anterior a primeira
                if (result) {
                    if (endDate.compareTo(beginDt) < 0) {
                        result = false;
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    private void saveCompensation() {
        try {
            if (validateDateCompensation()) {
                Configuration config = configurationDao.getConfiguration();
                Compensation comp = new Compensation();

                //carregar datas
                Date beginDt, endDate;
                beginDt = new SimpleDateFormat("dd/MM/yyyy").parse(dtBeginCompensation.getText().trim());
                endDate = new SimpleDateFormat("dd/MM/yyyy").parse(dtEndCompensation.getText().trim());

                //preencher compensation
                comp.setBeginDate(LocalDate.fromDateFields(beginDt));
                comp.setEndDate(LocalDate.fromDateFields(endDate));
                comp.setActive(cbCompensation.isSelected());
                //salvando
                config.setCompensation(comp);
                configurationDao.setConfiguration(config);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void loadCompensation(Compensation comp) {
        if (comp != null) {
            cbCompensation.setSelected(comp.isActive());
            activateCompensation(comp.isActive());
            dtBeginCompensation.setText(comp.getBeginDate().toString("dd/MM/yyyy"));
            dtEndCompensation.setText(comp.getEndDate().toString("dd/MM/yyyy"));

            calcCompensation();
        }
    }

    //gets and sets
    private LocalTime getTotal() {
        LocalTime totalHoras = new LocalTime(8, 0);
        try {

            LocalTime manha = getManha();
            LocalTime almoco2 = getAlmoco2();
            LocalTime tarde = getTarde();

            LocalTime totalManha = decreaseTime(getAlmoco(), manha.getHourOfDay(), manha.getMinuteOfHour());
            LocalTime totalTarde = decreaseTime(getTarde(), almoco2.getHourOfDay(), almoco2.getMinuteOfHour());
            totalHoras = increaseTime(totalManha, totalTarde.getHourOfDay(), totalTarde.getMinuteOfHour());

        } catch (Exception e) {
            e.printStackTrace();
        }
        return totalHoras;
    }

    private LocalTime getManha() throws Exception {
        manhaObj = manhaObj.withHourOfDay(Integer.parseInt(manhaH.getValue().toString()));
        manhaObj = manhaObj.withMinuteOfHour(Integer.parseInt(manhaM.getValue().toString()));
        return manhaObj;
    }

    private LocalTime getAlmoco() throws Exception {
        almocoObj = almocoObj.withHourOfDay(Integer.parseInt(almocoH.getValue().toString()));
        almocoObj = almocoObj.withMinuteOfHour(Integer.parseInt(almocoM.getValue().toString()));
        return almocoObj;
    }

    private LocalTime getAlmoco2() throws Exception {
        almoco2Obj = almoco2Obj.withHourOfDay(Integer.parseInt(almoco2H.getValue().toString()));
        almoco2Obj = almoco2Obj.withMinuteOfHour(Integer.parseInt(almoco2M.getValue().toString()));
        return almoco2Obj;
    }

    private LocalTime getTarde() throws Exception {
        tardeObj = tardeObj.withHourOfDay(Integer.parseInt(tardeH.getValue().toString()));
        tardeObj = tardeObj.withMinuteOfHour(Integer.parseInt(tardeM.getValue().toString()));
        return tardeObj;
    }

    private LocalTime getHPretendida() throws Exception {
        hPretendidaObj = hPretendidaObj.withHourOfDay(Integer.parseInt(hPretendidasH.getValue().toString()));
        hPretendidaObj = hPretendidaObj.withMinuteOfHour(Integer.parseInt(hPretendidasM.getValue().toString()));
        return hPretendidaObj;
    }

    private void activateCompensation(boolean key) {
        dtBeginCompensation.setEnabled(key);
        dtEndCompensation.setEnabled(key);
    }

    /**
     * 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() {

        jLabel6 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        btCalc = new javax.swing.JButton();
        btSave = new javax.swing.JButton();
        btLoadLast = new javax.swing.JButton();
        btShowHistory = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        hPretendidasH = new javax.swing.JSpinner();
        hPretendidasM = new javax.swing.JSpinner();
        dataAtual = new javax.swing.JFormattedTextField();
        lateTime = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        isTardeFix = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        result = new javax.swing.JLabel();
        isManhaFix = new javax.swing.JCheckBox();
        manhaH = new javax.swing.JSpinner();
        manhaM = new javax.swing.JSpinner();
        almocoH = new javax.swing.JSpinner();
        almocoM = new javax.swing.JSpinner();
        almoco2H = new javax.swing.JSpinner();
        almoco2M = new javax.swing.JSpinner();
        tardeH = new javax.swing.JSpinner();
        tardeM = new javax.swing.JSpinner();
        isAlmocoFix = new javax.swing.JCheckBox();
        isAlmoco2Fix = new javax.swing.JCheckBox();
        jPanel4 = new javax.swing.JPanel();
        cbCompensation = new javax.swing.JCheckBox();
        jLabel9 = new javax.swing.JLabel();
        dtBeginCompensation = new javax.swing.JFormattedTextField();
        jLabel10 = new javax.swing.JLabel();
        dtEndCompensation = new javax.swing.JFormattedTextField();
        jLabel11 = new javax.swing.JLabel();
        resultCompensation = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        jMenuItem3 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Calcula Ponto v.1.0.1.1");
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                formComponentShown(evt);
            }
        });
        addWindowStateListener(new java.awt.event.WindowStateListener() {
            public void windowStateChanged(java.awt.event.WindowEvent evt) {
                formWindowStateChanged(evt);
            }
        });
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jLabel6.setForeground(new java.awt.Color(0, 153, 255));
        jLabel6.setText("Feche a janela para manter o CalculaPonto minimizado prximo ao relgio.");

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        btCalc.setText("Calcular");
        btCalc.setToolTipText(
                "Clique aqui para calcular o total de horas e quando deve registrar o prximo ponto.");
        btCalc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCalcActionPerformed(evt);
            }
        });
        jPanel1.add(btCalc);

        btSave.setText("Salvar");
        btSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSaveActionPerformed(evt);
            }
        });
        jPanel1.add(btSave);

        btLoadLast.setText("Carregar ltima");
        btLoadLast.setToolTipText("Carregar ltima marcao no histrico");
        btLoadLast.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btLoadLastActionPerformed(evt);
            }
        });
        jPanel1.add(btLoadLast);

        btShowHistory.setText("Ver histrico");
        btShowHistory.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btShowHistoryActionPerformed(evt);
            }
        });
        jPanel1.add(btShowHistory);

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel7.setText("Horas pretendidas:");

        hPretendidasH.setToolTipText("");
        hPretendidasH.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                hPretendidasHMouseClicked(evt);
            }

            public void mousePressed(java.awt.event.MouseEvent evt) {
                hPretendidasHMousePressed(evt);
            }
        });
        hPretendidasH.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                hPretendidasHKeyReleased(evt);
            }

            public void keyTyped(java.awt.event.KeyEvent evt) {
                hPretendidasHKeyTyped(evt);
            }
        });

        hPretendidasM.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                hPretendidasMMouseClicked(evt);
            }
        });
        hPretendidasM.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                hPretendidasMPropertyChange(evt);
            }
        });
        hPretendidasM.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                hPretendidasMKeyPressed(evt);
            }
        });

        dataAtual.setEditable(false);
        try {
            dataAtual.setFormatterFactory(
                    new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        lateTime.setText("00:00");

        jLabel8.setText("Atraso Mensal:");

        jLabel12.setText("Data:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(jPanel2Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel8)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(lateTime).addGap(0, 0, Short.MAX_VALUE))
                                .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel7)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(hPretendidasH, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(hPretendidasM, javax.swing.GroupLayout.PREFERRED_SIZE, 47,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52,
                                                Short.MAX_VALUE)
                                        .addComponent(jLabel12)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(dataAtual, javax.swing.GroupLayout.PREFERRED_SIZE, 82,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap()));
        jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel7)
                        .addComponent(hPretendidasH, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(hPretendidasM, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(dataAtual, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel12)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel8).addComponent(lateTime))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        isTardeFix.setText("Marcao efetuada");
        isTardeFix.setToolTipText("Marque esta opo se j realizou esta marcao de ponto.");
        isTardeFix.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                isTardeFixActionPerformed(evt);
            }
        });

        jLabel1.setText("Manh");

        jLabel2.setText("Almoo");

        jLabel3.setText("Almoo");

        jLabel4.setText("Tarde");

        jLabel5.setText("Resultado:");

        result.setText("--");

        isManhaFix.setSelected(true);
        isManhaFix.setText("Marcao efetuada");
        isManhaFix.setToolTipText("Marque esta opo se j realizou esta marcao de ponto.");
        isManhaFix.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                isManhaFixActionPerformed(evt);
            }
        });

        manhaM.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                manhaMPropertyChange(evt);
            }
        });

        isAlmocoFix.setText("Marcao efetuada");
        isAlmocoFix.setToolTipText("Marque esta opo se j realizou esta marcao de ponto.");
        isAlmocoFix.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                isAlmocoFixActionPerformed(evt);
            }
        });

        isAlmoco2Fix.setText("Marcao efetuada");
        isAlmoco2Fix.setToolTipText("Marque esta opo se j realizou esta marcao de ponto.");
        isAlmoco2Fix.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                isAlmoco2FixActionPerformed(evt);
            }
        });

        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(jLabel1).addComponent(jLabel2).addComponent(jLabel3)
                                                .addComponent(jLabel4))
                                .addGap(33, 33, 33)
                                .addGroup(jPanel3Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel3Layout.createSequentialGroup()
                                                .addComponent(tardeH, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(tardeM, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(isTardeFix))
                                        .addGroup(jPanel3Layout.createSequentialGroup()
                                                .addComponent(almoco2H, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(almoco2M, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(isAlmoco2Fix))
                                        .addGroup(jPanel3Layout.createSequentialGroup()
                                                .addComponent(almocoH, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(almocoM, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(isAlmocoFix))
                                        .addGroup(jPanel3Layout.createSequentialGroup()
                                                .addComponent(manhaH, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(manhaM, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(isManhaFix))))
                        .addGroup(jPanel3Layout.createSequentialGroup().addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(result)))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(manhaH, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(manhaM, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel1).addComponent(isManhaFix))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(almocoH, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(almocoM, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel2).addComponent(isAlmocoFix))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(almoco2H, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(almoco2M, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel3).addComponent(isAlmoco2Fix))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(tardeH, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(tardeM, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel4).addComponent(isTardeFix))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel5).addComponent(result))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        cbCompensation.setText("Ativar compensao");
        cbCompensation.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbCompensationActionPerformed(evt);
            }
        });

        jLabel9.setText("Data incio:");

        try {
            dtBeginCompensation.setFormatterFactory(
                    new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        dtBeginCompensation.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dtBeginCompensationActionPerformed(evt);
            }
        });
        dtBeginCompensation.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                dtBeginCompensationKeyReleased(evt);
            }
        });

        jLabel10.setText("Data fim:");

        try {
            dtEndCompensation.setFormatterFactory(
                    new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        dtEndCompensation.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dtEndCompensationActionPerformed(evt);
            }
        });
        dtEndCompensation.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                dtEndCompensationKeyReleased(evt);
            }
        });

        jLabel11.setText("Resultado:");

        resultCompensation.setText("resultCompensacao");

        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.LEADING)
                                .addComponent(cbCompensation)
                                .addGroup(jPanel4Layout.createSequentialGroup().addComponent(jLabel9)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(dtBeginCompensation, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel10)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(dtEndCompensation, javax.swing.GroupLayout.PREFERRED_SIZE, 80,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel4Layout.createSequentialGroup().addComponent(jLabel11)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(resultCompensation)))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap().addComponent(cbCompensation)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel9)
                                .addComponent(dtBeginCompensation, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel10).addComponent(dtEndCompensation,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel11).addComponent(resultCompensation))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        jMenu1.setText("Configurao");

        jMenuItem2.setText("Fazer Backup");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuItem1.setText("Restaurar backup");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);
        jMenu1.add(jSeparator1);

        jMenuItem3.setText("Preferncias");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createSequentialGroup()
                                .addGroup(
                                        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jLabel6)
                                                .addComponent(jPanel2, 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)
                                                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel4, 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(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel6)
                        .addContainerGap()));

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

    private void manhaMPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_manhaMPropertyChange
    }//GEN-LAST:event_manhaMPropertyChange

    private void hPretendidasHKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_hPretendidasHKeyTyped
        setTime();
    }//GEN-LAST:event_hPretendidasHKeyTyped

    private void hPretendidasHMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_hPretendidasHMouseClicked
        setTime();
    }//GEN-LAST:event_hPretendidasHMouseClicked

    private void btCalcActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCalcActionPerformed
        setTime();
        addRegToHistory();
        lateTime.setText(registroBO.getLateTimeByMonth(new Date()).toString("HH:mm"));
        calcCompensation();
    }//GEN-LAST:event_btCalcActionPerformed

    private void hPretendidasHKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_hPretendidasHKeyReleased
        setTime();
    }//GEN-LAST:event_hPretendidasHKeyReleased

    private void hPretendidasHMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_hPretendidasHMousePressed
        setTime();
    }//GEN-LAST:event_hPretendidasHMousePressed

    private void hPretendidasMKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_hPretendidasMKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_hPretendidasMKeyPressed

    private void hPretendidasMMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_hPretendidasMMouseClicked
        setTime();
    }//GEN-LAST:event_hPretendidasMMouseClicked

    private void hPretendidasMPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_hPretendidasMPropertyChange
        setTime();
    }//GEN-LAST:event_hPretendidasMPropertyChange

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        try {
            calc();
            trayManager.criarTrayIcon();
            trayManager.adicionarATray();
            dataAtual.setText(new SimpleDateFormat("dd/MM/yyyy").format(new Date()));
        } catch (AWTException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_formWindowClosing

    private void btShowHistoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btShowHistoryActionPerformed
        new Historico(this, true).setVisible(true);
    }//GEN-LAST:event_btShowHistoryActionPerformed

    private void isTardeFixActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_isTardeFixActionPerformed
        addRegToHistory();
    }//GEN-LAST:event_isTardeFixActionPerformed

    private void isAlmoco2FixActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_isAlmoco2FixActionPerformed
        addRegToHistory();
    }//GEN-LAST:event_isAlmoco2FixActionPerformed

    private void isAlmocoFixActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_isAlmocoFixActionPerformed
        addRegToHistory();
    }//GEN-LAST:event_isAlmocoFixActionPerformed

    private void isManhaFixActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_isManhaFixActionPerformed
        addRegToHistory();
    }//GEN-LAST:event_isManhaFixActionPerformed

    private void formWindowStateChanged(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowStateChanged
        if (dataAtual != null) {
            dataAtual.setText(new SimpleDateFormat("dd/MM/yyyy").format(new Date()));
        }
    }//GEN-LAST:event_formWindowStateChanged

    private void btLoadLastActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLoadLastActionPerformed
        loadLastRegistry();
    }//GEN-LAST:event_btLoadLastActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        restoreBackup();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        backup();
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        Configs configs = new Configs(this, true);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void cbCompensationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbCompensationActionPerformed
        if (cbCompensation.isSelected()) {
            activateCompensation(true);
            calcCompensation();
        } else {
            activateCompensation(false);
            resultCompensation.setText("00:00 horas");
        }
        saveCompensation();
    }//GEN-LAST:event_cbCompensationActionPerformed

    private void dtBeginCompensationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dtBeginCompensationActionPerformed
        calcCompensation();
    }//GEN-LAST:event_dtBeginCompensationActionPerformed

    private void dtEndCompensationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dtEndCompensationActionPerformed
        calcCompensation();
    }//GEN-LAST:event_dtEndCompensationActionPerformed

    private void dtBeginCompensationKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dtBeginCompensationKeyReleased
        saveCompensation();
    }//GEN-LAST:event_dtBeginCompensationKeyReleased

    private void dtEndCompensationKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dtEndCompensationKeyReleased
        saveCompensation();
    }//GEN-LAST:event_dtEndCompensationKeyReleased

    private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
        dataAtual.setText(new SimpleDateFormat("dd/MM/yyyy").format(new Date()));
    }//GEN-LAST:event_formComponentShown

    private void btSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSaveActionPerformed
        btSaveAction();
    }//GEN-LAST:event_btSaveActionPerformed

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

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new NewJFrame().setVisible(true);
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Erro:" + e.getMessage());
                    e.printStackTrace();
                }
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JSpinner almoco2H;
    private javax.swing.JSpinner almoco2M;
    private javax.swing.JSpinner almocoH;
    private javax.swing.JSpinner almocoM;
    private javax.swing.JButton btCalc;
    private javax.swing.JButton btLoadLast;
    private javax.swing.JButton btSave;
    private javax.swing.JButton btShowHistory;
    private javax.swing.JCheckBox cbCompensation;
    private javax.swing.JFormattedTextField dataAtual;
    private javax.swing.JFormattedTextField dtBeginCompensation;
    private javax.swing.JFormattedTextField dtEndCompensation;
    private javax.swing.JSpinner hPretendidasH;
    private javax.swing.JSpinner hPretendidasM;
    private javax.swing.JCheckBox isAlmoco2Fix;
    private javax.swing.JCheckBox isAlmocoFix;
    private javax.swing.JCheckBox isManhaFix;
    private javax.swing.JCheckBox isTardeFix;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    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 jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JLabel lateTime;
    private javax.swing.JSpinner manhaH;
    private javax.swing.JSpinner manhaM;
    private javax.swing.JLabel result;
    private javax.swing.JLabel resultCompensation;
    private javax.swing.JSpinner tardeH;
    private javax.swing.JSpinner tardeM;
    // End of variables declaration//GEN-END:variables
}