Hi clecer people!

I am new can i have a little help here please.
I wanted to mcuh the name and password of employee,
entering and exiting the building

( it works but not completely)

The task

Implement a system that restricts which members of staff that have access to
a secure building. Only authorized employees are allowed entry to the
building. Each employee will consists of at least a user name (which is
unique) and a password. he software should allow for, amongst other things:
addEmployee
accepts a name and password, and adds this pair to the collection of
authorized personnel.
removeEmployee
removes a specified employee from the list of authorized employees,
providing that that person is not currently inside the building.
enter
accepts a name and password;
if these details match an entry in the authorized list, then the
individual is granted entry to the building;
if the details are incorrect an alarm is signalled.
leave
accepts a name of an employee;
if this individual is currently recorded as being inside the building they
are allowed to depart;
if the employee is not inside the building an alarm is signalled.

.

 import java.awt.*; // ekofo elvis/////
 import java.awt.event.*; 
 import javax.swing.*; 
 import javax.swing.table.*; 
 import java.io.*;
 import java.util.*;
 /**
 * Class to provide the functionality system 
 * for the record of Club points
 *@Author ELVIS - EKOFO
 *@VERSION 26TH APR-2010
 *
 */ 

 public class InterJobCentre extends JFrame 
 { 
 /**
 * Class to provide GUI for football application
 * elvis ekofo
 * 
 * @version 2010 /april.
 */
    final int Over_All = 7;
    final String[] columns = {"SeekerName", "JobId", "skill","Much number"};
    private JMenuBar jmb= new JMenuBar();
    private JMenu fileMenu = new JMenu("File");
    private JMenuItem jmiOpen = new JMenuItem("Open");
    private JMenuItem jmiSave= new JMenuItem("Save");
    private JMenuItem jmiExit = new JMenuItem("Exit");
    private JLabel lblHead;
    private JLabel lblClubName; 
    private JLabel lblQualify; 
    private JLabel lblLoose; 
    private JLabel lblPoints; 
    private JLabel jlblPicture;
    private JTextField txtClubName; 
    private JTextField txtQualify; 
    private JTextField txtLoose; 
    private JTextField txtPoints; 
    private JTable tblRecord; 
    private DefaultTableModel model;
    private JScrollPane jScrollPane1;
    private JPanel buttonPanel = new JPanel(); 
    private JPanel contentPane; 
    private JButton btnOK;
    private JButton btnEdit;
    private JButton btnTakeOff;
    private JButton btnAdd;
    private JButton btnGame;
    private JButton btnShow;
    private JFileChooser jfc = new JFileChooser();
    // End of variables declaration 


    public InterJobCentre() 
    { 
        super();

        initializeComponent();


        // 
        // TODO: Add any constructor code after initializeComponent call 
        // 

        this.setVisible(true); 
    } 

    /** 
     * 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 Windows Form Designer. Otherwise, retrieving design might not work properly. 
     * Tip: If you must revise this method, please backup this GUI file for JFrameBuilder 
     * to retrieve your design properly in future, before revising this method. 
     */ 
    private void initializeComponent() 
    { 


        setJMenuBar(jmb);
        jmb.add(fileMenu);
        fileMenu.setMnemonic('F');
        fileMenu.add(jmiOpen);
        fileMenu.add(jmiSave);
        fileMenu.add(jmiExit);
        lblHead = new JLabel();
        lblClubName = new JLabel(); 
        lblQualify = new JLabel(); 

        lblLoose = new JLabel(); 
        lblPoints = new JLabel(); 
        txtClubName = new JTextField(); 
        txtQualify = new JTextField(); 
        txtLoose = new JTextField(); 
        txtPoints = new JTextField(); 
        txtPoints.setEditable(false);
        model = new DefaultTableModel();
        tblRecord = new JTable(model);
        jScrollPane1 = new JScrollPane(); 
        contentPane = (JPanel)this.getContentPane(); 
        btnOK = new JButton();
        btnEdit = new JButton();
        btnTakeOff = new JButton();
        btnAdd = new JButton();
        btnGame = new JButton();
        btnShow = new JButton();
        jlblPicture = new JLabel();



        //
        //lblHead
        //
        lblHead.setHorizontalAlignment(SwingConstants.CENTER);
        lblHead.setText("This is a JobCentre System ");

        // 
        // lblClubName 
        // 
        lblClubName.setHorizontalAlignment(SwingConstants.CENTER); 
        lblClubName.setText("JobSeek'sName"); 
        // 
        // lblQualify 
        // 
        lblQualify.setHorizontalAlignment(SwingConstants.CENTER); 
        lblQualify.setText("you id"); 
        // 
        // lblLoose 
        // 
        lblLoose.setHorizontalAlignment(SwingConstants.CENTER); 
        lblLoose.setText("Skill"); 
        // 
        // lblPoints 
        // 
        lblPoints.setHorizontalAlignment(SwingConstants.CENTER); 
        lblPoints.setText("Points"); 
        // 
        // txtClubName 
        // 
        txtClubName.addActionListener(new ActionListener() 
        { 
            public void actionPerformed(ActionEvent e) 
            { 
                txtClubName_actionPerformed(e); 
            } 
        }); 
        // 
        // txtQualify 
        // 
        txtQualify.addActionListener(new ActionListener() 
        { 
            public void actionPerformed(ActionEvent e) 
            { 

                txtQualify_actionPerformed(e); 
            } 
        }); 
        txtQualify.addKeyListener(new KeyAdapter()
        {

            public void keyTyped(KeyEvent e)
            {
                char c = e.getKeyChar();
                if (!((c >= '0') && (c <= '9') ||
                   (c == KeyEvent.VK_BACK_SPACE) ||
                   (c == KeyEvent.VK_DELETE))) 
                    {
                        getToolkit().beep();
                        e.consume();
                        return;
                    }
               try
                {
                   int Qualify = 0;

                   if (c == KeyEvent.VK_BACK_SPACE || c == KeyEvent.VK_DELETE)
                       Qualify = Integer.parseInt("0" + txtQualify.getText());
                   else
                       Qualify = Integer.parseInt(txtQualify.getText() + String.valueOf(c));
                    int points = Qualify * Over_All;
                    txtPoints.setText(new Integer(points).toString());

                }
                catch(NumberFormatException ex)
                {
                    JOptionPane.showMessageDialog(null, "Qualify field should have String");

                    txtQualify.setText("");
                } 
            }
        });

        // 
        // txtLoose 
        // 
        txtLoose.addActionListener(new ActionListener() 
        { 
            public void actionPerformed(ActionEvent e) 
            { 
                txtLoose_actionPerformed(e); 
            } 
        }); 
        // 
        // txtPoints 
        // 
        txtPoints.addActionListener(new ActionListener() 
        { 
            public void actionPerformed(ActionEvent e) 
            { 
                txtPoints_actionPerformed(e); 
            }  
        }); 
        //
        // jScrollPane1 
        // 
        jScrollPane1.setViewportView(tblRecord); 
        //
        //btnOK
        //
        btnOK.setText("ENTER");
        btnOK.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                btnOK_actionPerformed(e);
            }
        });
        //
        //btnEdit
        //
        btnEdit.setText("Edit");
        btnEdit.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                btnEdit_actionPerformed(e);
            }
        });
        //
        //btnTakeOff
        //
        btnTakeOff.setText("TakeOff");
        btnTakeOff.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                btnTakeOff_actionPerformed(e);
            }
        });
        //
        //btnAdd
        //
        btnAdd.setText("Add");
        btnAdd.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                btnAdd_actionPerformed(e);
            }
        });

        btnGame.setText("JOBLIST");//use to be search
        btnGame.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                btnGame_actionPerformed(e);
            }
        });
        jlblPicture.setIcon(new ImageIcon ("elvis.jpj"));
        jmiOpen.setText("Open");
        jmiOpen.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                jmiOpen_actionPerformed(e);
            }
        });
        jmiSave.setText("Save");
        jmiSave.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                jmiSave_actionPerformed(e);
            }
        });
        jmiExit.setText("Exit");
        jmiExit.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                jmiExit_actionPerformed(e);
            }
        });
        // 
        // contentPane 
        // 
        contentPane.setLayout(null); 
        contentPane.setBorder(BorderFactory.createEtchedBorder()); 
        addComponent(contentPane, lblHead, 125,10,150,40);
        addComponent(contentPane, lblClubName, 12,49,68,32); 
        addComponent(contentPane, lblQualify, 115,48,48,26); 
        addComponent(contentPane, lblLoose, 166,49,74,23); 
        addComponent(contentPane, lblPoints, 236,51,66,22); 
        addComponent(contentPane, txtClubName, 22,85,85,22); 
        addComponent(contentPane, txtQualify, 122,85,42,22); 
        addComponent(contentPane, txtLoose, 182,84,47,22); 
        addComponent(contentPane, txtPoints, 247,84,45,22);
        addComponent(contentPane, btnOK, 300,84,105,22);
        addComponent(contentPane, jScrollPane1, 24,165,277,84);
        addComponent(contentPane, btnEdit, 25,255,75,22);
        addComponent(contentPane, btnTakeOff,120, 255,85,22);
        addComponent(contentPane, btnAdd,225,255,75,22);
        addComponent(contentPane, btnGame,305,167,75,75);
        addComponent(contentPane, jlblPicture,455,267,175,175);
        //Add Columns to the Table
        for (int i=0; i<columns.length; i++)
            model.addColumn(columns[i]);

        //Fill Data from the file into tblRecord
        boolean checkFile = true;
        ArrayList records = null;
        try
        {
            records = new ArrayList();
            BufferedReader reader = new BufferedReader(new FileReader("Result.txt"));
            String record = null;
            while((record = reader.readLine()) != null)
            {
                records.add(record);
            }
            reader.close();
        }
        catch(FileNotFoundException fnfe)
        {
            checkFile = false;
        }
        catch(IOException ioe)
        {
            checkFile = false;
        }
        Vector data = null;
        if (checkFile)
        {
            for(int i=0; i<records.size(); i++)
            {
                String fields[] = ((String)records.get(i)).split("]");
                data = new Vector();
                for (int j=0; j<fields.length; j++)
                {
                    //System.out.println(fields[j].substring(1));
                    data.add(fields[j].substring(1));
                }
                model.addRow(data);

            }
        }
        // 
        // Title to be Display on the top 
        // 
        this.setTitle("***SECURITY BUILDING ****"); 
        this.setLocation(new Point(10, 0)); 
        this.setSize(new Dimension(499, 371)); 
    } 

    /** Add Component Without a Layout Manager (Absolute Positioning) */ 
    private void addComponent(Container container,Component c,int x,int y,int width,int height) 
    { 
        c.setBounds(x,y,width,height); 
        container.add(c); 
    } 
    private void makeEmpty()
    {
        txtClubName.setText("");
        txtQualify.setText("");
        txtLoose.setText("");
        txtPoints.setText("");
    }
    private void btnOK_actionPerformed(ActionEvent e)
    {
        if (txtClubName.getText().equals("")|| txtQualify.getText().equals("") || txtLoose.getText().equals(""))
        {
            JOptionPane.showMessageDialog(null,"Enter your  name,iD number And Skill "); 
            makeEmpty();
            txtClubName.requestFocus();
            return;
        }
        Vector row = new Vector();
        row.add(txtClubName.getText());
        row.add(txtQualify.getText());
        row.add(txtLoose.getText());
        row.add(txtPoints.getText());
        JOptionPane.showMessageDialog(null,"Adding to Table, Click "Add" to effect in File");
        model.addRow(row);
        makeEmpty();        
    }
    private void btnEdit_actionPerformed(ActionEvent e)
    {
        int[] rownum = tblRecord.getSelectedRows();
        if (rownum.length == 0)
        {
            JOptionPane.showMessageDialog(null, "Select Row to Rewrite");
            return;
        }
        if (rownum.length > 1)
        {
            JOptionPane.showMessageDialog(null, "Can't Edit more than 1 Row at a time");
            return;
        }

        txtClubName.setText(tblRecord.getValueAt(rownum[0],0).toString());
        txtQualify.setText(tblRecord.getValueAt(rownum[0],1).toString());
        txtLoose.setText(tblRecord.getValueAt(rownum[0],2).toString());
        txtPoints.setText(tblRecord.getValueAt(rownum[0],3).toString());
        model.removeRow(rownum[0]);

    }

    private void btnAdd_actionPerformed(ActionEvent e)
    {
        int flag = JOptionPane.showConfirmDialog(null,"Want to Add File with these details","Confirm",JOptionPane.YES_NO_OPTION);
        if (flag == JOptionPane.NO_OPTION)
            return;
        int cols = tblRecord.getColumnCount();
        int rows = tblRecord.getRowCount();
        String[] data = new String[rows];
        StringBuffer buf = null;
        for(int i=0; i<rows; i++)
        {
            buf = new StringBuffer();
            buf.append("[");
            for (int j=0; j<cols;j++)
            {
                if (j == cols-1)
                    buf.append(tblRecord.getValueAt(i,j).toString()+ "]");
                else
                    buf.append(tblRecord.getValueAt(i,j).toString() + "][");
            }
            data[i] = buf.toString();
            //System.out.println(data[i]);
        }
        try
        {
            PrintWriter writer = new PrintWriter("Result.txt");
            for (int i=0; i<rows; i++)
                writer.println(data[i]);
            writer.close();
        }
        catch(IOException ioe)
        {
        }
        JOptionPane.showMessageDialog(null, "File Added successfully");

    }

    private void btnTakeOff_actionPerformed(ActionEvent e)
    {
        System.out.println(tblRecord.getSelectedRow());
        int[] rownum = tblRecord.getSelectedRows();
        if (rownum.length == 0)
        {
            JOptionPane.showMessageDialog(null, "computingjava");
            return;//(null, "Select Row in the Table to TakeOff");

        }
        if (rownum.length > 1)
        {
            JOptionPane.showMessageDialog(null, " wRong mouvement,Make sure you Take off no more than 1 Row");
            return;
        }
        int flag = JOptionPane.showConfirmDialog(null," Are your sure want to dalete the row?","Confirm",JOptionPane.YES_NO_OPTION);
        if (flag == JOptionPane.NO_OPTION)
            return;
        model.removeRow(rownum[0]);
        JOptionPane.showMessageDialog(null, "TakeOff from Table not from File, Click "Add" Button to Add the File");
    }

    private void btnGame_actionPerformed(ActionEvent e)
    {
        //
    }
    private void jmiOpen_actionPerformed(ActionEvent e)
    {
        if (jfc.showOpenDialog(this)==JFileChooser.APPROVE_OPTION)
             {
                File fileName = jfc.getSelectedFile();
                String filePath = fileName.getAbsolutePath();
                open(filePath);
             }

    }
    private void jmiSave_actionPerformed(ActionEvent e)
    {

              if (jfc.showSaveDialog(this)==JFileChooser.APPROVE_OPTION)
             {
                File fileName = jfc.getSelectedFile();
                String filePath = fileName.getAbsolutePath();
                save(filePath);
             }



    }
        private void jmiExit_actionPerformed(ActionEvent e)
    {

             int answer = JOptionPane.showConfirmDialog(this, "are you sure you want to quit", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
             if (answer == JOptionPane.YES_OPTION)
            {
              System.exit(0);
            }
    }

    // 
    // TODO: Add any appropriate code in the following Event Handling Methods 
    // 
    private void txtClubName_actionPerformed(ActionEvent e) 
    { 
        System.out.println("ntxtClubName_actionPerformed(ActionEvent e) called."); 
        // TODO: Add any handling code here 
    } 

    private void txtQualify_actionPerformed(ActionEvent e) 
    { 
        System.out.println("ntxtQualify_actionPerformed(ActionEvent e) called."); 
        // TODO: Add any handling code here 
    } 

    private void txtLoose_actionPerformed(ActionEvent e) 
    { 
        System.out.println("ntxtLoose_actionPerformed(ActionEvent e) called."); 
        // TODO: Add any handling code here 
    } 

    private void txtPoints_actionPerformed(ActionEvent e) 
    { 
        System.out.println("ntxtPoints_actionPerformed(ActionEvent e) called."); 
        // TODO: Add any handling code here 
    } 

    // 
    // TODO: Add any method code to meet your needs in the following area 
    // 

private void open(String fileName)
  {
     try
     {

       JOptionPane.showMessageDialog(this, "planes loaded","Information", JOptionPane.INFORMATION_MESSAGE);
     }
     catch (Exception e)
     {
        JOptionPane.showMessageDialog
             (this, e.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE);

     }
  }
  private void save(String fileName)
  {
     try
     {

      JOptionPane.showMessageDialog(this, "planes saved","Information", JOptionPane.INFORMATION_MESSAGE);
     }
     catch (Exception e)
     {
        JOptionPane.showMessageDialog
             (this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);

     }
  }

 public static void main(String[] args) 
    { 

        new InterJobCentre(); 
    } 


 }

it works but not completely

Do you have any specific questions about your project?

Please put your code in code tags. Use the icon at upper right of input area.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.