<file_sep>package ui;

/**
 *
 * @author DEGUZMAN
 */
public final class Constants {

    public static final String DONT_EXIST = "dont exist";
    public static final String EXIST = "exist";
    public static final String ERROR = "error";
    public static final String HOST = "127.0.0.1";
    public static final int PORT = 8888;
    
    public static final String VERIFY_ADMIN_REQUEST = "verify admin";
    public static final String GENERATE_ACCOUNT_REQUEST = "generate account";
    public static final String ADD_CUSTOMER_REQUEST = "add customer";
    public static final String VERIFY_CUSTOMER_REQUEST = "verify customer";
    public static final String CHECK_FINGERPRINT_REQUEST = "check if fingerprint exist";
    public static final String ADD_ACCOUNT_REQUEST = "add account";
    public static final String GET_ID_REQUEST = "get id";
    public static final String GET_ACCOUNTS_REQUEST = "get accounts";
    public static final String GET_ACCOUNT_BALANCES_REQUEST = "get account balances";
    public static final String GET_NAMES_REQUEST = "get names";
    
    public static final String ACTION_SUCCESSFUL = "successful";
    public static final String ACTION_UNSUCCESSFUL = "unsuccessful";
    
    public static final String FIRST_NAME = "first_name";
    public static final String LAST_NAME = "last_name";
    public static final String ID_NUMBER = "id_number";
    public static final String ACCOUNT_NUMBER = "account_number";
    public static final String PASSWORD = "<PASSWORD>";
    public static final String PRINT = "print";
    public static final String USERNAME = "username";

    private Constants() {
        //this prevents even the native class from calling this ctor as well :
        throw new AssertionError();
    }
}
<file_sep>/*
 * 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 ui;

import java.awt.Cursor;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;

/**
 *
 * @author DEGUZMAN
 */
public class LoginPanel extends javax.swing.JPanel {
    DocumentListener listener = new MyDocumentListener();
    /**
     * Creates new form LoginPanel
     */
    public LoginPanel() {
        initComponents();
        usernameField.getDocument().addDocumentListener(listener);
        passwordField.getDocument().addDocumentListener(listener);
    }

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

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        usernameField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        passwordField = new javax.swing.JPasswordField();
        loginButton = new javax.swing.JButton();
        exitButton = new javax.swing.JButton();

        jLabel1.setText("Login");

        jLabel2.setText("User - name :");

        jLabel3.setText("Password:");

        loginButton.setText("Log in");
        loginButton.setEnabled(false);
        loginButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loginButtonActionPerformed(evt);
            }
        });

        exitButton.setText("Exit");
        exitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(exitButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(loginButton))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(usernameField, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(passwordField))))
                .addContainerGap(30, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(usernameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(loginButton)
                    .addComponent(exitButton))
                .addContainerGap(42, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginButtonActionPerformed
       new Thread(this::verifyAdmin).start();
    }//GEN-LAST:event_loginButtonActionPerformed

    private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed
        AdminFrame.getHomePanel().showPanel(HomePanelController.WELCOME_PANEL);
    }//GEN-LAST:event_exitButtonActionPerformed

    public void verifyAdmin() {
        String username = usernameField.getText();
        String password = <PASSWORD>.valueOf(<PASSWORD>());
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        loginButton.setEnabled(false);
        try {
            String response = Connector.verifyAdmin(username, password);
            if (response.equalsIgnoreCase("EXIST")) {
                AdminFrame.getHomePanel().getWelcomePanel().setLoginButton(false);
                AdminFrame.getHomePanel().getWelcomePanel().setLogoutButton(true);
                AdminFrame.getHomePanel().showPanel(HomePanelController.WELCOME_PANEL);
                AdminFrame.setButtonsStatus(true);
            } else if (response.equalsIgnoreCase("NOT FOUND")) {
                JOptionPane.showMessageDialog(this, "Not Authorised", "Info", JOptionPane.INFORMATION_MESSAGE);
            } else {
                JOptionPane.showMessageDialog(this, response, "Info", JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (IOException ex) {
            //Logger.getLogger(LoginPanel.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null, "Error: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }
        setCursor(null);
        loginButton.setEnabled(true);
    }

    public static void main(String[] arf) {
        JFrame frame = new JFrame("Loging in");
        frame.add(new LoginPanel());

        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton exitButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JButton loginButton;
    private javax.swing.JPasswordField passwordField;
    private javax.swing.JTextField usernameField;
    // End of variables declaration//GEN-END:variables

    class MyDocumentListener implements DocumentListener {

        @Override
        public void insertUpdate(DocumentEvent e) {
            loginButton.setEnabled(!usernameField.getText().equals("") && passwordField.getPassword().length > 0);
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            loginButton.setEnabled(!usernameField.getText().equals("") && passwordField.getPassword().length > 0);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            loginButton.setEnabled(!usernameField.getText().equals("") && passwordField.getPassword().length > 0);
        }

    }
}
<file_sep>package ui;

import java.awt.Cursor;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

public class DetailsForm extends javax.swing.JPanel {

    MyDocumentListener listener = new MyDocumentListener();

    /**
     * Creates new form DetailsForm
     */
    public DetailsForm() {
        initComponents();
        firstNameField.getDocument().addDocumentListener(listener);
        lastNameField.getDocument().addDocumentListener(listener);
        idField.getDocument().addDocumentListener(listener);
        passwordField.getDocument().addDocumentListener(listener);
        confirmPasswordField.getDocument().addDocumentListener(listener);
    }

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

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        firstNameField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        lastNameField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        idField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        passwordField = new javax.swing.JPasswordField();
        confirmPasswordField = new javax.swing.JPasswordField();
        generateAccountButton = new javax.swing.JButton();
        accountLabel = new javax.swing.JLabel();
        okButton = new javax.swing.JButton();
        exitButton = new javax.swing.JButton();
        confirmationLabel = new javax.swing.JLabel();
        passwordSizeLabel = new javax.swing.JLabel();

        jLabel1.setText("Customers Details");

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel2.setText("First name");

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel3.setText("Last name");

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel4.setText("Id number");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel5.setText("Password");

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel6.setText("Confirm");

        generateAccountButton.setText("Generate account number.");
        generateAccountButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                generateAccountButtonActionPerformed(evt);
            }
        });

        accountLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        accountLabel.setText("_");

        okButton.setText("Ok");
        okButton.setEnabled(false);
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });

        exitButton.setText("Exit");
        exitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitButtonActionPerformed(evt);
            }
        });

        confirmationLabel.setForeground(new java.awt.Color(255, 0, 0));
        confirmationLabel.setText("  ");

        passwordSizeLabel.setForeground(new java.awt.Color(255, 0, 0));
        passwordSizeLabel.setText("  ");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(exitButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(okButton))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 211, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(firstNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(lastNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(idField, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(generateAccountButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(accountLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(confirmationLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(confirmPasswordField)))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(passwordSizeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(passwordField)))))
                .addContainerGap(159, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(firstNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(lastNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(idField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(passwordSizeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 21, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(confirmPasswordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(confirmationLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(generateAccountButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(accountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(okButton)
                    .addComponent(exitButton))
                .addGap(27, 27, 27))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed
        AdminFrame.getAddPanel().showPanel(AddPanelController.SCANNING_PANEL);
    }//GEN-LAST:event_exitButtonActionPerformed

    private void generateAccountButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateAccountButtonActionPerformed
        new Thread(this::getAndSetAccount).start();
    }//GEN-LAST:event_generateAccountButtonActionPerformed

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
        if (!Arrays.equals(passwordField.getPassword(), confirmPasswordField.getPassword())) {
            JOptionPane.showMessageDialog(this, "Confirmed password should be equal to the password", "Info", JOptionPane.ERROR_MESSAGE);
            return;
        }

        if (confirmDetails()) {
            BufferedImage print = AdminFrame.getAddPanel().getScanningPanel().getPrint();
            new Thread(() -> addCustomer(getDetails(), print)).start();
        }
    }//GEN-LAST:event_okButtonActionPerformed

    public Map<String, String> getDetails() {
        Map<String, String> details = new HashMap<>();
        details.put(Constants.FIRST_NAME, firstNameField.getText());
        details.put(Constants.LAST_NAME, lastNameField.getText());
        details.put(Constants.ID_NUMBER, idField.getText());
        details.put(Constants.ACCOUNT_NUMBER, accountLabel.getText());
        details.put(Constants.PASSWORD, String.valueOf(passwordField.getPassword()));
        return details;
    }

    public boolean confirmDetails() {
        String message = String.format("%13s : %-15s %n%13s : %-15s %n%13s : %-15s %n%13s : %-15s",
                "First name", firstNameField.getText(),
                "Last name", lastNameField.getText(),
                "ID number", idField.getText(), 
                "Account", accountLabel.getText() );

        int choice = JOptionPane.showConfirmDialog(this, message, "Confirm", JOptionPane.OK_CANCEL_OPTION);
        return (choice == JOptionPane.OK_OPTION);
    }

    private void processResponse(String response) {
        JOptionPane.showMessageDialog(this, response);
        if (response.equalsIgnoreCase("SUCCESS")) {
            AdminFrame.getAddPanel().showPanel(AddPanelController.SCANNING_PANEL);
        }
    }

    public void addCustomer(Map<String, String> details, BufferedImage image) {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        okButton.setEnabled(false);
        try {
            String response = Connector.addCustomer(details, image);
            processResponse(response);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        setCursor(null);
        resetFields();
        okButton.setEnabled(true);
    }

    public void setOkButton() {
        boolean status = !"_".equals(accountLabel.getText()) && confirmPasswordField.getPassword().length > 0 && !"".equals(firstNameField.getText())
                && !"".equals(idField.getText()) && !"".equals(lastNameField.getText()) && passwordField.getPassword().length > 0;
        okButton.setEnabled(status);

    }

    public void getAndSetAccount() {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        generateAccountButton.setEnabled(false);
        try {
            String account = Connector.generateAccountNumber();
            SwingUtilities.invokeLater(() -> {
                accountLabel.setText(account);
                setOkButton();
            });
        } catch (Exception ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(this, ex.getMessage(), "Info", JOptionPane.ERROR_MESSAGE);
        }
        setCursor(null);
        generateAccountButton.setEnabled(true);
    }

    public void resetFields() {
        accountLabel.setText("_");
        confirmPasswordField.setText("");
        passwordField.setText("");
        firstNameField.setText("");
        lastNameField.setText("");
        idField.setText("");
    }

    class MyDocumentListener implements DocumentListener {

        @Override
        public void insertUpdate(DocumentEvent e) {
            set();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            set();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            set();
        }

        public void set() {
            int passwordSize = passwordField.getPassword().length;
            boolean passwordSizeOk = passwordSize > 0 && passwordSize >= 6;
            String s = (passwordSize > 0 && passwordSize < 6) ? ("Password length must be greater than 6 characters"): (" ");
            passwordSizeLabel.setText(s);
            
            boolean passwordEqual = Arrays.equals(passwordField.getPassword(), confirmPasswordField.getPassword());
            s = (confirmPasswordField.getPassword().length > 0 && !passwordEqual) ? ("Password should be the same") : (" ");
            confirmationLabel.setText(s);
            
            boolean status = !"_".equals(accountLabel.getText()) && 
                    passwordEqual && 
                    !"".equals(firstNameField.getText()) && 
                    !"".equals(idField.getText()) && 
                    !"".equals(lastNameField.getText()) && 
                    passwordSizeOk;
            okButton.setEnabled(status);
        }

    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel accountLabel;
    private javax.swing.JPasswordField confirmPasswordField;
    private javax.swing.JLabel confirmationLabel;
    private javax.swing.JButton exitButton;
    private javax.swing.JTextField firstNameField;
    private javax.swing.JButton generateAccountButton;
    private javax.swing.JTextField idField;
    private javax.swing.JLabel jLabel1;
    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.JTextField lastNameField;
    private javax.swing.JButton okButton;
    private javax.swing.JPasswordField passwordField;
    private javax.swing.JLabel passwordSizeLabel;
    // End of variables declaration//GEN-END:variables

    public static void main(String[] args) {
        JFrame frame = new JFrame("Details form");
        frame.add(new DetailsForm());
        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}//334
<file_sep>package ui;

import java.awt.Cursor;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;

public class ScanningPanel extends javax.swing.JPanel {

    GUITimer timer = new GUITimer();

    /**
     * Creates new form scanningPanel
     */
    public ScanningPanel() {
        initComponents();
        addMouseListener(timer);
        timer.start();
    }

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

        jLabel1 = new javax.swing.JLabel();
        printLabel = new javax.swing.JLabel();

        jLabel1.setText("Scan fingerprint");

        printLabel.setBackground(new java.awt.Color(255, 255, 255));
        printLabel.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
        printLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                printLabelMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(printLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(28, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(printLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(33, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void printLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_printLabelMouseClicked
        String filePath = getPath();
        setIcon(new ImageIcon(filePath));

        try {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            String id = getIdForPrint(ImageIO.read(new File(filePath)));
            setCursor(null);
            processResponse(id);
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this.getParent(), ex.getMessage());
            ex.printStackTrace();
        } finally {
            setCursor(null);
            reset();
        }
    }//GEN-LAST:event_printLabelMouseClicked

    private void processResponse(String response) {
        if (response.equals("")) {
            JOptionPane.showMessageDialog(this.getParent(), "Print not found");
            return;
        } else if (response.startsWith("ERROR")) {
            JOptionPane.showMessageDialog(this.getParent(), response, "Error", JOptionPane.INFORMATION_MESSAGE);
            CustomerFrame.showPanel(CustomerFrame.WELCOME_PANEL);
            return;
        }

        authenticate(response);
    }

    private String getPassword() {
        JPasswordField passwordField = new JPasswordField();
        JOptionPane pane = new JOptionPane();
        pane.setMessage(passwordField);

        JDialog dialog = pane.createDialog(this.getParent(), "Enter password");
        dialog.setModal(true);
        dialog.setVisible(true);
        dialog.dispose();

        String password = String.valueOf(passwordField.getPassword());
        return password;
    }

    public void authenticate(String id) {
        for (int trials = 0; trials < 3; trials++) {
            String password = getPassword();
            String result = verifyCustomer(id, password);
            
            if (result.equalsIgnoreCase("EXIST")) {
                CustomerFrame.showPanel(CustomerFrame.ACTION_PANEL);
                CustomerFrame.setCustomerId(id);
                break;
            } else if (result.equalsIgnoreCase("NOT FOUND")) {
            } else {
                JOptionPane.showMessageDialog(this.getParent(), result, "Error", JOptionPane.INFORMATION_MESSAGE);
                CustomerFrame.showPanel(CustomerFrame.WELCOME_PANEL);
            }
        }
    }

    private String verifyCustomer(String id, String password) {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        String result;
        try {
            result = ClientConnector.verifyCustomer(id, password);
        } catch (IOException ex) {
            CustomerFrame.showPanel(CustomerFrame.WELCOME_PANEL);
            result = "ERROR:" + ex.getMessage();
            ex.printStackTrace();
        }
        setCursor(null);
        return result;
    }

    /**
     * prompts for the path of the print
     *
     * @return the path of the selected print
     */
    private String getPath() {
        JFileChooser fileChooser = new PictureChooser();
        int result = fileChooser.showOpenDialog(null);
        if (result == JFileChooser.CANCEL_OPTION) {
            return null;
        }
        File fileName = fileChooser.getSelectedFile(); //get file
        //display error if invalid
        if ((fileName == null) || (fileName.getName().equals(""))) {
            JOptionPane.showMessageDialog(this, "Invalid Name", "error", JOptionPane.ERROR_MESSAGE);
            return null;
        }
        return fileName.getPath();
    }

    private void setIcon(ImageIcon img) {
        SwingUtilities.invokeLater(() -> {
            Image image = img.getImage().getScaledInstance(printLabel.getWidth(), printLabel.getHeight(), Image.SCALE_SMOOTH);
            printLabel.setIcon(new ImageIcon(image));
        });

    }

    private String getIdForPrint(BufferedImage image) throws IOException {
        return ClientConnector.getIdForPrint(image);
    }

    /**
     * sets the print label to null
     */
    public void reset() {
        printLabel.setIcon(null);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    public javax.swing.JLabel printLabel;
    // End of variables declaration//GEN-END:variables

    public static void main(String[] s) {
        JFrame frame = new JFrame("Scanning panel");
        frame.add(new ScanningPanel());
        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
} //200
<file_sep>package adminserver;

import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.imageio.ImageIO;
import sourcefiles.FingerprintMatcher;
import sourcefiles.FingerprintTemplate;

/**
 *An implementation of finding the location of a fingerprint image from the provided
 * @author DEGUZMAN
 */
public class FingerprintFinder {
    String[] printsLocation;
    FingerprintMatcher matcher;
    String location = "";
    ExecutorService executor ;

    /**
     * Takes the prints location 
     * @param prints 
     */
    public FingerprintFinder(String[] prints) {
        printsLocation = prints;
    }

    String find(BufferedImage image) {
        FingerprintTemplate probe = new FingerprintTemplate().create(loadImage(image));
        matcher = new FingerprintMatcher().index(probe);
        executor = Executors.newCachedThreadPool();
        MatchingThread [] threads = new MatchingThread[printsLocation.length];
        for(int i = 0; i < printsLocation.length; i++){
            threads[i] = new MatchingThread(printsLocation[i]);
            executor.execute(threads[i]);
        }
        executor.shutdown(); // shut down worker threads when their tasks complete
        
        return getLocation();
    }
    
    synchronized private String getLocation(){
        while("".equals(location) && !executor.isTerminated())
            try {
                wait();
            } catch (InterruptedException ex) {
            }
        
        return location;
    }
    
    synchronized private void setLocation(String location){
        this.location = location;
        executor.shutdownNow();
        notifyAll();
    }
    
    private byte[] loadImage(BufferedImage bImage) {
        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            ImageIO.write(bImage, "jpg", bos);

            byte[] data = bos.toByteArray();
            return data;
        } catch (Exception e) {
        }
        return new byte[0];
    }
    
    class MatchingThread implements Runnable{
        String printToMatch;
        public MatchingThread(String print) {
            this.printToMatch = print;
        }

        @Override
        public void run() {
            try {
                BufferedImage image = ImageIO.read(new File(printToMatch));
                FingerprintTemplate matching = new FingerprintTemplate().create(loadImage(image));
                if (matcher.match(matching) > 40 ) setLocation(printToMatch);
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        
    }
}
<file_sep>package ui;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 *
 * @author DEGUZMAN
 */
public class TimeThread extends MouseAdapter implements Runnable {

    int loadingtime = 30000;
    int time = loadingtime; //30 seconds
    ThreadAction action; //what to do when time elapses

    public TimeThread(ThreadAction action) {
        this.action = action;
    }

    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(1000);
                setTime(time -= 1000);
                if (time <= 0) {
                    action.action();
                    setTime(loadingtime);
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    synchronized void setTime(int value) {
        time = value;
    }

    @Override
    public void mouseMoved(MouseEvent e) {
        setTime(loadingtime);
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        setTime(loadingtime);
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        setTime(loadingtime);
    }

}
<file_sep>//make sure to make it a must to pass credentials for each request
package clientserver;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

public class SocketHandler implements Runnable {

    Socket socket;
    ObjectInputStream inputStream;
    ObjectOutputStream outputStream;

    /**
     * initializes the SocketHandler
     *
     * @param socket the socket to process
     */
    public SocketHandler(Socket socket) {
        this.socket = socket;
        setStreams();
    }

    private void setStreams() {
        try {
            inputStream = new ObjectInputStream(socket.getInputStream());
            outputStream = new ObjectOutputStream(socket.getOutputStream());
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    /**
     * reads the request and call the appropriate method to process the request
     */
    @Override
    public void run() {
        try (IOClosable closer = socket::close) {
            String request = inputStream.readUTF();
            switch (request.toLowerCase()) {
                case Constants.GET_ID_REQUEST:
                    readPrintReturnId();
                    break;
                case Constants.GET_ACCOUNT_REQUEST:
                    getAccounts();
                    break;
                case Constants.VERIFY_PASSWORD_REQUEST:
                    verifyPassword();
                    break;
                case Constants.GET_ACCOUNT_BALANCES_REQUEST:
                    getAccountBalances();
                    break;
                case Constants.WITHDRAW_REQUEST:
                    withdraw();
                    break;
                default: //do nothing
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * perform the withdraw action
     */
    private void withdraw() throws Exception {
        String response = "";
        try {
            Map<String, String> data = (Map<String, String>) inputStream.readObject();
            response = Database.withdraw(data.get(Constants.ID_NUMBER), data.get(Constants.ACCOUNT_NUMBER), Double.parseDouble(data.get("amount")));
        } catch (IOException | ClassNotFoundException | NumberFormatException | SQLException ex) {
            response = "Error withdrawing cash. Try again later";
            throw ex;
        } finally {
            sendString(response);
        }
    }

    /**
     * process getting of customers accounts and balances in the accounts
     */
    private void getAccountBalances() {
        String response = "";
        try {
            String id = inputStream.readUTF();
            Map<String, String> result;
            try {
                result = Database.getAccountBalances(id);
            } catch (Exception ex) {
                result = new HashMap<>();
                result.put("Error", ex.getMessage());
            }
            outputStream.writeObject(result);
            return;
        } catch (IOException ex) {
            ex.printStackTrace();
            response = ex.getMessage();
        }
    }

    /**
     * used to verify customer credentials
     */
    private void verifyPassword() {
        String result;
        try {
            Map<String, String> map = (Map<String, String>) inputStream.readObject();
            result = (verifyCustomer(map.get("id_number"), map.get("password"))) ? Constants.ACCOUNT_NUMBER : "NOT FOUND";
        } catch (Exception ex) {
            //Logger.getLogger(SocketHandler.class.getName()).log(Level.SEVERE, null, ex);
            ex.printStackTrace();
            result = ex.getMessage();
        }

        try {
            sendString(result);
        } catch (IOException ex) {
            //Logger.getLogger(SocketHandler.class.getName()).log(Level.SEVERE, null, ex);
            ex.printStackTrace();
        }
    }

    /**
     * verify if a customer with the given id_number and password exist
     *
     * @param id_number the id number of the customer
     * @param password the password of the customer
     * @return true if the customer exist otherwise false
     * @throws SQLException
     */
    private boolean verifyCustomer(String id_number, String password) throws SQLException {
        return Database.customerExist(id_number, password);
    }

    /**
     * gets the accounts of particular id read from sockets. sends result back
     * as a string array
     */
    private void getAccounts() throws SQLException, IOException {
        String[] accounts = new String[1];
        try {
            String id = inputStream.readUTF();
            accounts = Database.getAccounts(id);
        } catch (IOException ex) {
            accounts[0] = "An error occured getting the accounts. Try again later or check with the bank"; 
            throw ex;
        } finally{
            outputStream.writeObject(accounts);
        }
    }

    /**
     * reads a print from the socket and sends back the id number of the print
     * stored in the database
     */
    private void readPrintReturnId() throws Exception {
        String result = "";
        try {
            String minutiae = inputStream.readUTF();
            result = getIDForMinutiae(minutiae);
        } catch (IOException | SQLException ex) {
            result = "Error processing print. Try again later or check with the bank";
            throw ex;
        } finally {
            sendString(result);
        }
    }

    /**
     * used to retrieve the ID of the customer with the given finger-print
     * minutiae
     *
     * @param minutiae the minutiae of the customer
     * @return id number
     * @throws SQLException
     */
    private String getIDForMinutiae(String minutiae) throws SQLException {
        return Database.getMinutiaeID(minutiae);
    }

    /**
     * used to send a string across the socket
     *
     * @param value the string to send
     * @throws IOException throws an exception if an error occurs during sending
     */
    private void sendString(String value) throws IOException {
        outputStream.writeUTF(value);
        outputStream.flush();
    }
}
//201
<file_sep>package ui;

import java.awt.Cursor;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author DEGUZMAN
 */
public class SearchPanel extends javax.swing.JPanel {

    /**
     * Creates new form SearchPanel
     */
    public SearchPanel() {
        initComponents();
        idField.getDocument().addDocumentListener(new FieldListener());
    }

    /**
     * Retrieve names of a customer using {@link Connector} class
     *
     * @param id the id number of the person to retrieve names
     * @return the names of the customer
     */
    public Map<String, String> getNames(String id) throws IOException {
        return Connector.getNames(id);
    }

    /**
     * Retrieve accounts and balances using {@link Connector} class
     *
     * @param id the id number of the person to retrieve accounts and balances
     * @return the balances mapped to the accounts
     */
    public Map<String, String> getAccountsAndBalances(String id) throws IOException{
        return Connector.getAccountBalances(id);
    }

    /**
     * Clear the name textfields
     */
    public void clear() {
        firstNameField.setText(" ");
        lastNameField.setText(" ");
    }

    public void search() {
        tableModel.clear();
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (Connector.connectionExist()) {
            try {
                String id = idField.getText();
                Map<String, String> names = getNames(id);
                firstNameField.setText(names.get("first_name"));
                lastNameField.setText(names.get("last_name"));
                
                tableModel.updateTable(id);
            } catch (IOException ex) {
                JOptionPane.showMessageDialog(this, ex.getMessage());
            }
        }else {
            JOptionPane.showMessageDialog(this.getParent(), "There is no connetion with the Server", "Connection Error", JOptionPane.ERROR_MESSAGE);
        }

        setCursor(null);
    }

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

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        idField = new javax.swing.JTextField();
        searchButton = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        firstNameField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        lastNameField = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        accountTable = new javax.swing.JTable();

        jLabel1.setText("Search customer");

        jLabel2.setText("ID:");

        idField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                idFieldActionPerformed(evt);
            }
        });

        searchButton.setText("Search");
        searchButton.setEnabled(false);
        searchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchButtonActionPerformed(evt);
            }
        });

        jLabel3.setText("First name:");

        firstNameField.setEditable(false);
        firstNameField.setBackground(new java.awt.Color(255, 255, 255));
        firstNameField.setDisabledTextColor(new java.awt.Color(0, 0, 0));

        jLabel4.setText("Last name:");

        lastNameField.setEditable(false);
        lastNameField.setBackground(new java.awt.Color(255, 255, 255));
        lastNameField.setDisabledTextColor(new java.awt.Color(0, 0, 0));

        jScrollPane1.setBackground(new java.awt.Color(255, 255, 255));
        jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jScrollPane1.setToolTipText("accounts");

        accountTable.setModel(tableModel);
        accountTable.setColumnSelectionAllowed(true);
        accountTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        accountTable.setShowVerticalLines(false);
        jScrollPane1.setViewportView(accountTable);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(firstNameField))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(18, 18, 18)
                                .addComponent(idField, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lastNameField)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(searchButton))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(45, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(idField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(searchButton))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(firstNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lastNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(31, 31, 31)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(27, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed
        new Thread(this::search).start();
    }//GEN-LAST:event_searchButtonActionPerformed

    private void idFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idFieldActionPerformed
        new Thread(this::search).start();
    }//GEN-LAST:event_idFieldActionPerformed

    public static void main(String [] args){
        JFrame frame = new JFrame("Search Panel");
        frame.add(new SearchPanel());
        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
    
    class AccountsTableModel extends AbstractTableModel {

        Map<String, String> data = new HashMap<>();
        String[] keys = {};

        @Override
        public int getRowCount() {
            return data.size();
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public String getValueAt(int rowIndex, int columnIndex) {
            return columnIndex == 0 ? keys[rowIndex] : data.get(keys[rowIndex]);
        }

        //get name of a particular column in ResultSet
        @Override
        public String getColumnName(int column) {
            return column == 0 ? "Account" : "Balance";
        }

        /**
         * update the data in the table
         *
         * @param id the id number of the individual whose data will fill the
         * table
         */
        public void updateTable(String id) throws IOException {
            data = SearchPanel.this.getAccountsAndBalances(id); //refresh the data of the table
            keys = data.keySet().toArray(new String[data.size()]);
            fireTableDataChanged();
        }

        public void clear() {
            data.clear();
            fireTableDataChanged();
        }
    }

    class FieldListener implements DocumentListener {

        @Override
        public void insertUpdate(DocumentEvent e) {
            setSearchButton();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            setSearchButton();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            setSearchButton();
        }

        private void setSearchButton() {
            searchButton.setEnabled(!idField.getText().equals(""));
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable accountTable;
    private javax.swing.JTextField firstNameField;
    private javax.swing.JTextField idField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField lastNameField;
    private javax.swing.JButton searchButton;
    // End of variables declaration//GEN-END:variables

    AccountsTableModel tableModel = new AccountsTableModel();
}
<file_sep>package ui;

import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.Timer;

public class GUITimer extends MouseAdapter {
    private final int loadingtime = 120000; //2 minutes
    private final Timer timer ;
    boolean actionOccured = false;

    public GUITimer() {
        timer = new Timer(loadingtime, (ActionEvent e) -> {
            GUITimer.this.run();
        });
    }
    
    public void start(){
        timer.start();
    }
    
    public void stop(){
        timer.stop();
    }

    public void run() {
        if (actionOccured) {
            setActionOccurred(false);
        }
        else {
            CustomerFrame.showPanel(CustomerFrame.WELCOME_PANEL);
        }
    }

    synchronized void setActionOccurred(boolean value) {
        actionOccured = value;
    }

    @Override
    public void mouseMoved(MouseEvent e) {
        System.out.println("mouse moved");
        setActionOccurred(true);
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        System.out.println("mouse released");
        setActionOccurred(true);
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        System.out.println("mouse entered");
        setActionOccurred(true);
    }

}
<file_sep>/*
 * 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 ui;

import java.awt.CardLayout;

/**
 *
 * @author DEGUZMAN
 */
public final class CustomerFrame extends javax.swing.JFrame {
    private static String customerId;
    private static final CardLayout card = new CardLayout();
    
    private static final WelcomePanel   welcomePanel    = new WelcomePanel();
    private static final ScanningPanel  scanningPanel   = new ScanningPanel();
    private static final ActionPanel    actionPanel     = new ActionPanel();
    private static final WithdrawPanel  withdrawPanel   = new WithdrawPanel();
    
    TimeThread timeThread = new TimeThread(()-> {showPanel(WELCOME_PANEL);} );
    Thread thread = new Thread(timeThread);
    GUITimer timer = new GUITimer();
    
    public static final String WELCOME_PANEL = "welcome_panel";
    public static final String SCANNING_PANEL = "scanning_panel";
    public static final String ACTION_PANEL = "action_panel";
    public static final String WITHDRAW_PANEL = "withdraw_panel";
    
    public CustomerFrame() {
        initComponents();
        
        card.addLayoutComponent(welcomePanel, WELCOME_PANEL);
        card.addLayoutComponent(scanningPanel, SCANNING_PANEL);
        card.addLayoutComponent(actionPanel, ACTION_PANEL);
        card.addLayoutComponent(withdrawPanel, WITHDRAW_PANEL);
        
        mainPanel.setLayout(card);
        mainPanel.add(welcomePanel);
        mainPanel.add(scanningPanel);
        mainPanel.add(actionPanel);
        mainPanel.add(withdrawPanel);
        
        //thread.start();
        addMouseListener(timer);
        timer.start();
    }

    public  static String getCustomerId() {
        return customerId;
    }

    public static void setCustomerId(String Id) {
        customerId = Id;
    }

    public static void showPanel(String panelName) {
        if (panelName.equalsIgnoreCase(SCANNING_PANEL)) scanningPanel.reset();
        else if (panelName.equalsIgnoreCase(WELCOME_PANEL)) setCustomerId("");
        else if (panelName.equalsIgnoreCase(WITHDRAW_PANEL)) withdrawPanel.reset();
        card.show(mainPanel, panelName);
    }

    public static WelcomePanel getWelcomePanel() {
        return welcomePanel;
    }

    public static ScanningPanel getScanningPanel() {
        return scanningPanel;
    }

    public static ActionPanel getActionPanel() {
        return actionPanel;
    }

    public static WithdrawPanel getWithdrawPanel() {
        return withdrawPanel;
    }
    
    
    
    /**
     * 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() {

        mainPanel = new java.awt.Panel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setUndecorated(true);
        setPreferredSize(new java.awt.Dimension(400, 300));
        setResizable(false);

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(mainPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 306, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(mainPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );

        setSize(new java.awt.Dimension(400, 306));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

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

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(() -> {
            new CustomerFrame().setVisible(true);
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private static java.awt.Panel mainPanel;
    // End of variables declaration//GEN-END:variables
}
<file_sep>/*
 * 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 adminserver;

import java.awt.Cursor;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Date;
import java.util.Scanner;
import java.util.logging.Level;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;

/**
 *
 * @author DEGUZMAN
 */
public class ServerApp extends javax.swing.JFrame {

    /**
     * Creates new form ServerApp
     */
    public ServerApp() {
        initComponents();
    }

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

        controlPanel = new javax.swing.JPanel();
        startButton = new javax.swing.JButton();
        stopButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        infoArea = new javax.swing.JTextArea();
        jMenuBar1 = new javax.swing.JMenuBar();
        viewMenu = new javax.swing.JMenu();
        serverInfoMenuItem = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        connectionsMenuItem = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        clearLogsMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        aboutMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Admin Server");
        addWindowStateListener(new java.awt.event.WindowStateListener() {
            public void windowStateChanged(java.awt.event.WindowEvent evt) {
                formWindowStateChanged(evt);
            }
        });

        controlPanel.setBackground(new java.awt.Color(102, 102, 102));

        startButton.setText("Start");
        startButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startButtonActionPerformed(evt);
            }
        });

        stopButton.setText("Stop");
        stopButton.setEnabled(false);
        stopButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stopButtonActionPerformed(evt);
            }
        });

        infoArea.setColumns(20);
        infoArea.setFont(new java.awt.Font("Lucida Console", 0, 12)); // NOI18N
        infoArea.setLineWrap(true);
        infoArea.setRows(5);
        infoArea.setToolTipText("information area");
        infoArea.setWrapStyleWord(true);
        infoArea.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        infoArea.setEnabled(false);
        infoArea.setSelectionColor(new java.awt.Color(255, 255, 255));
        jScrollPane1.setViewportView(infoArea);

        javax.swing.GroupLayout controlPanelLayout = new javax.swing.GroupLayout(controlPanel);
        controlPanel.setLayout(controlPanelLayout);
        controlPanelLayout.setHorizontalGroup(
            controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(controlPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
                    .addGroup(controlPanelLayout.createSequentialGroup()
                        .addComponent(startButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(stopButton)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        controlPanelLayout.setVerticalGroup(
            controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(controlPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(startButton)
                    .addComponent(stopButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                .addContainerGap())
        );

        getContentPane().add(controlPanel, java.awt.BorderLayout.CENTER);

        viewMenu.setText("View");

        serverInfoMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.CTRL_MASK));
        serverInfoMenuItem.setText("Server info");
        serverInfoMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                serverInfoMenuItemActionPerformed(evt);
            }
        });
        viewMenu.add(serverInfoMenuItem);

        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem2.setText("Logs");
        viewMenu.add(jMenuItem2);

        connectionsMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        connectionsMenuItem.setText("Connections");
        connectionsMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                connectionsMenuItemActionPerformed(evt);
            }
        });
        viewMenu.add(connectionsMenuItem);
        viewMenu.add(jSeparator1);

        clearLogsMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.SHIFT_MASK));
        clearLogsMenuItem.setText("Clear logs");
        clearLogsMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearLogsMenuItemActionPerformed(evt);
            }
        });
        viewMenu.add(clearLogsMenuItem);

        jMenuBar1.add(viewMenu);

        helpMenu.setText("Help");

        aboutMenuItem.setText("About");
        helpMenu.add(aboutMenuItem);

        jMenuBar1.add(helpMenu);

        setJMenuBar(jMenuBar1);

        setBounds(0, 0, 366, 270);
    }// </editor-fold>//GEN-END:initComponents

    private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed
        new Thread(this::startServer).start();
    }//GEN-LAST:event_startButtonActionPerformed

    private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopButtonActionPerformed
        new Thread(this::stopServer).start();
    }//GEN-LAST:event_stopButtonActionPerformed

    private void formWindowStateChanged(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_formWindowStateChanged

    private void connectionsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectionsMenuItemActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_connectionsMenuItemActionPerformed

    private void clearLogsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearLogsMenuItemActionPerformed
        SwingUtilities.invokeLater(() -> infoArea.setText(""));
    }//GEN-LAST:event_clearLogsMenuItemActionPerformed

    private void serverInfoMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_serverInfoMenuItemActionPerformed
        JTextArea display = new JTextArea();
        new Thread(() -> readFile("server_info_log.txt", display)).start();
        JOptionPane.showMessageDialog(this, new JScrollPane(display), "Server info", WIDTH);
        JOptionPane pane = new JOptionPane();
        
    }//GEN-LAST:event_serverInfoMenuItemActionPerformed

    private void readFile(String file_name, JTextArea displayArea) {
        try {
            FileInputStream inputStream = new FileInputStream(new File("server_info_log.txt"));
            Scanner scanner = new Scanner(new File("server_info_log.txt"));
            while(scanner.hasNext())
                displayArea.append(scanner.next());
        } catch (FileNotFoundException ex) {
            displayArea.append(ex.getMessage() + "\n");
        }
    }
    
    private void startServer() {
        display("Starting server");
        startButton.setEnabled(false);
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        try {
            Server.start();
            display("Server started " + Server.isRunning());
            log(Level.INFO, "Server started " + Server.isRunning());
            stopButton.setEnabled(Server.isRunning());
            startButton.setEnabled(!Server.isRunning());
            if (Server.isRunning()) new Thread(this::notifier).start();
            display("Database connection exist: " + Database.checkConnection());
            log(Level.INFO, "Database connection exist: " + Database.checkConnection());
        } catch (IOException ex) {
            log(Level.SEVERE, ex.getMessage());
            display("Error while starting server " + ex.getMessage());
            ex.printStackTrace();
        }
        setCursor(null);

    }
    
    private void stopServer() {
        display("Stopping server");
        stopButton.setEnabled(false);
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        try {
            Server.stop();
            display("Server stopped\nServer running: " + Server.isRunning());
            log(Level.INFO, "Server stopped: " );
            startButton.setEnabled(!Server.isRunning());
            stopButton.setEnabled(Server.isRunning());

            display("Database connected: " + Database.checkConnection());
            log(Level.INFO, "Database connected: " + Database.checkConnection() );
        } catch (IOException ex) {
            log(Level.SEVERE, ex.getMessage());
            display("Error while stopping server " + ex.getMessage());
        }
        setCursor(null);
    }

    /**
     * displays a message on the infoArea at Event dispatch thread
     *
     * @param message the message to be displayed
     */
    private void display(String message) {
        SwingUtilities.invokeLater(() -> infoArea.append(message + " ( " + DateFormat.getDateTimeInstance().format(new Date()) + " )\n"));
    }
    
    /**
     * used to log a message into the logger file
     * 
     * @param level the level of the message
     * @param message the message to be logged
     */
    private void log(Level level, String message){
        ServerInfoLog.log(Level.INFO, "Server started " + Server.isRunning());
    }

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JMenuItem clearLogsMenuItem;
    private javax.swing.JMenuItem connectionsMenuItem;
    private javax.swing.JPanel controlPanel;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JTextArea infoArea;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JMenuItem serverInfoMenuItem;
    private javax.swing.JButton startButton;
    private javax.swing.JButton stopButton;
    private javax.swing.JMenu viewMenu;
    // End of variables declaration//GEN-END:variables

    public void notifier() {
        while (Server.isRunning()) {
            display("Server running \nDatabase connected " + Database.checkConnection());
            try {
                Thread.sleep(10000);
            } catch (InterruptedException ex) {
            }
        }
    }

class WindowChecker extends WindowAdapter {

    @Override
    public void windowClosing(WindowEvent e) {
        ServerApp.this.stopServer();
    }

    @Override
    public void windowClosed(WindowEvent e) {
        if (!Server.isRunning()) {
            JOptionPane.showMessageDialog(null, "Server could not stop running", "Error", JOptionPane.ERROR);
        }
    }
}
}
<file_sep>package clientserver;
//throw illigelState if db not connected
//add logging

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Database {

    private static Connection connection;

    static { //executedd once to setup the database
        connect();
    }

    Database() {
        connect();
    }

    /**
     * setup connection to the database
     */
    public static void connect() {
        try {
            connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/project", "root", "");
        } catch (SQLException ex) {
            //Logger.getLogger(Database.class.getName()).log(Level.SEVERE, "Could not connect to database", ex);
            System.err.println("Could not connect to database");
        }
    }

    /**
     * closes connection to the database
     */
    public static void disconnect() {
        try {
            connection.close();
        } catch (SQLException ex) {
            //Logger.getLogger(Database.class.getName()).log(Level.SEVERE, "Could not connect to database", ex);
            System.err.println("Could not close to database");
        }
    }

    /**
     * checks if there is a connection with the database and tries to connect if there is no connection
     * @return true if a connection exist
     */
    public static boolean checkConnection() {
        if (!connectionExist())
            connect();
        return connectionExist();
    }

    /**
     * Checks if a connection to the database exist
     *
     * @return true if there is a connection otherwise false
     */
    public static boolean connectionExist() {
        try {
            return connection != null && connection.isValid(100);
        } catch (SQLException ex) {
            Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }

    /**
     * checks if a customer exists in a database. NB. Checks only customers who have set passwords
     *
     * @param id_number
     * @param password
     * @return return true if a customer with the given id_number exist otherwise false
     * @throws java.sql.SQLException if an error occurred while reading the database
     */
    public static boolean customerExist(String id_number, String password) throws SQLException{
        String query = "SELECT id_number FROM passwords WHERE id_number = '" + id_number + "' AND password = '" + password + "'";

        try (Statement statement = connection.createStatement();
                ResultSet resultSet = statement.executeQuery(query)) {
            return resultSet.next(); //true if data exist
        } 
    }

    //id not needed here
    /**
     * used to get the balance in a specified account of a customer
     *
     * @param id_number the id number of the customer
     * @param account_number the account number of the customer
     * @return the balance of the customer in the account number
     * @throws java.sql.SQLException if there is an error reading the database
     */
    public static double getBalance(String id_number, String account_number) throws SQLException {
        String query = "SELECT balance FROM accounts WHERE id_number = '" + id_number + "' AND account_number = '" + account_number + "'";
        try (Statement statement = connection.createStatement();
                ResultSet resultSet = statement.executeQuery(query)) {
            if (resultSet.next()) {
                return resultSet.getFloat(1);
            }
            throw new SQLException("Account not found");
        }
    }

    /**
     * used to fetch all the accounts of a given customer
     *
     * @param id_number the id number of the customer
     * @return all the accounts of a customer in form of a String array
     * @throws java.sql.SQLException if there was an error reading the accounts
     */
    public static String[] getAccounts(String id_number) throws SQLException {
        String query = "SELECT account_number FROM accounts WHERE id_number = '" + id_number + "'";
        ArrayList<String> accountNumbers = new ArrayList<>(1);

        try (Statement statement = connection.createStatement();
                ResultSet resultSet = statement.executeQuery(query)) {
            while (resultSet.next()) {
                accountNumbers.add(resultSet.getString(1));
            }
        }
        return accountNumbers.toArray(new String[accountNumbers.size()]);
    }

    /**
     * locates the id number for the minutiae
     *
     * @param minutiae the minutiae of the print
     * @return the id_number of the fingerprint
     * @throws java.sql.SQLException if there is an error reading the prints from the database
     */
    public static String getMinutiaeID(String minutiae) throws SQLException {
        return new MinutiaeFinder(getMinutiae()).find(minutiae);
    }

    /**
     * used to get the balances of all the accounts registered on a given id
     * number
     *
     * @param idNumber the id number of the customer
     * @return the accounts and their balances
     * @throws Exception
     */
    public static Map<String, String> getAccountBalances(String idNumber) throws Exception {
        String query = "SELECT account_number, balance FROM accounts WHERE id_number = '" + idNumber + "'";
        Map<String, String> accounts = new HashMap<>();

        try (Statement statement = connection.createStatement();
                ResultSet resultSet = statement.executeQuery(query)) {
            while (resultSet.next()) {
                accounts.put(resultSet.getString("account_number"), resultSet.getString("balance"));
            }
        }
        return accounts;
    }
    
    /**
     * get all the print locations stored in the database
     *
     * @return returns locations stored as a String array
     * @throws SQLException throws SQLException if there is an error reading the
     * database
     */
    private static Map<String,String> getMinutiae() throws SQLException {
        Map<String,String> minutiae = new HashMap<>();
        String query = "SELECT * FROM fingerprints"; 
        try (Statement statement = connection.createStatement();
                ResultSet resultSet = statement.executeQuery(query)) {

            while (resultSet.next()) { //iterate the result set
                minutiae.put(resultSet.getString(1), resultSet.getString(2)); 
            }
        } 
        return minutiae;
    }

    /**
     * Deducts the amount of money from the account
     *
     * @param idNumber the id number of the customer
     * @param account the account number of the customer
     * @param amount the amount to withdraw
     * @return response which can be either {@link Constants.ACTION_SUCCESSFUL} if withdraw was successful or {@link Constants.ACTION_UNSUCCESSFUL} if withdraw was unsuccessful
     * or a message if the balance is less
     * @throws java.sql.SQLException if an error occurred when deducting cash
     */
    public static String withdraw(String idNumber, String account, double amount) throws SQLException {
        if( getBalance(idNumber, account) < amount){
            return "Your account is low on cash";
        }
        String query = "update accounts set balance = balance - '" + amount + "' where id_number = '" + idNumber + "' and account_number = '" + account + "'";
        try (Statement statement = connection.createStatement()) {
            int result = statement.executeUpdate(query);
            return result > 0 ? Constants.ACTION_SUCCESSFUL : Constants.ACTION_UNSUCCESSFUL;
        } 
    }

    /**
     * deposits money to the given account of a id number
     *
     * @param idNumber the id number of the customer
     * @param account the account number of the customer
     * @param amount the amount to deposit
     * @return either {@link Constants.ACTION_SUCCESSFUL} if deposit was successful or {@link Constants.ACTION_SUCCESSFUL} if deposit was unsuccessful 
     * @throws java.sql.SQLException when an error is encountered
     */
    public static String deposit(String idNumber, String account, float amount) throws SQLException{
        String query = "update accounts set balance = balance + '" + amount + "' where id_number = '" + idNumber + "' and account_number = '" + account + "'";
        try (Statement statement = connection.createStatement()) {
            int result = statement.executeUpdate(query);
            return result > 0 ? Constants.ACTION_SUCCESSFUL : Constants.ACTION_UNSUCCESSFUL ;
        } 
    }
}//241
<file_sep>package ui;

import java.awt.CardLayout;
import javax.swing.*;

public final class AddPanelController extends JPanel {

    private CardLayout card = new CardLayout();
    private final ScanningPanel scanningPanel = new ScanningPanel();
    private final AddAccountPanel addAccountPanel = new AddAccountPanel();
    private final DetailsForm detailsForm = new DetailsForm();
    public static final String SCANNING_PANEL = "scanning_panel";
    public static final String ADD_ACCOUNT_PANEL = "add_account_panel";
    public static final String DETAILS_PANEL = "details_panel";

    public AddPanelController() {
        card.addLayoutComponent(scanningPanel, SCANNING_PANEL);
        card.addLayoutComponent(addAccountPanel, ADD_ACCOUNT_PANEL);
        card.addLayoutComponent(detailsForm, DETAILS_PANEL);

        this.setLayout(card);

        add(scanningPanel);
        add(addAccountPanel);
        add(detailsForm);
    }

    public AddAccountPanel getAddAccountPanel() {
        return addAccountPanel;
    }

    public ScanningPanel getScanningPanel() {
        return scanningPanel;
    }

    public AddAccountPanel getPasswordPanel() {
        return addAccountPanel;
    }

    public DetailsForm getDetailsForm() {
        return detailsForm;
    }

    public void showPanel(String panelName) {
        if (panelName.equalsIgnoreCase(SCANNING_PANEL)) {
            scanningPanel.getSubmitButton().setEnabled(false);
            scanningPanel.getFingerprintLabel().setIcon(null);
        } else if (panelName.equalsIgnoreCase(ADD_ACCOUNT_PANEL)) {
            addAccountPanel.reset();
        }
        card.show(this, panelName);
    }

}//49
