Results 1 to 3 of 3
  1. #1
    jacob.pham is offline Member
    Join Date
    Jul 2010
    Posts
    1
    Rep Power
    0

    Smile I want to add, search, edit, delete record of employee

    :)Hi,

    I want to add, search edit and delete record of employees then save to file .txt
    but i don't know how to do it

    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    
    public class manager {
        private JFrame f;
        private JTabbedPane tp;
        private JPanel p1, p2, p3, p4;
        private JButton btn1, btn2;
        private JLabel l1, l2, l3;
        private JTextField t1, t2, t3;
        
        manager() 
        {    	 
            p1 = new JPanel(new GridLayout(4,2));
            p2 = new JPanel(new GridLayout(3,3));
            p3 = new JPanel(new GridLayout(3,3));
            p4 = new JPanel(new GridLayout(3,3));        
            
            btn1 = new JButton("Submit");
            btn2 = new JButton("Reset");
             
            p1.add(l1 = new JLabel("Employee ID"));
            p1.add(t1 = new JTextField(10));
            p1.add(l2 = new JLabel("Employee Name"));
            p1.add(t2 = new JTextField(10));
            p1.add(l3 = new JLabel("Employee Address"));
            p1.add(t3 = new JTextField(10));
            p1.add(btn1);
            p1.add(btn2);
            
            btn1.addActionListener(new ActionListener()
            {
            	public void ActionPerformed(ActionEvent ae)
            	{
            		String s1 = t1.getText();
            		String s2 = t2.getText();
            		String s3 = t3.getText();
            		
            		if(s1=="" || s2=="" || s3=="")
            		{
            			return;
            		}
            		
            			
            		        		
            	}
            });
            
            btn2.addActionListener(new ActionListener(){
            	public void actionPerformed(ActionEvent e)
            	{
            		t1.setText("");
            		t2.setText("");
            		t3.setText("");
            	}
            });
            
    
        }
      
        public void launchFrame() 
        {
        	JFrame.setDefaultLookAndFeelDecorated(true);
            f = new JFrame("Hello khakhakha!");
            
            tp = new JTabbedPane();
            
        	Container c = f.getContentPane();
        	c.add(tp);
        	
        	tp.addTab("Add record", p1);
        	tp.addTab("Edit record", p2);
        	tp.addTab("Search record", p3);
        	tp.addTab("Delete record", p4);
        	
        	f.pack();
            //f.setSize(400,200);
            f.setVisible(true);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
    
        
        public static void main(String args[]) {
            manager guiWindow = new manager();
            guiWindow.launchFrame();
        }
    }

    Can you help me!
    Thanks a lot.

    Moderator Edit: Code tags added
    Last edited by Fubarable; 07-16-2010 at 06:29 AM. Reason: Moderator Edit: Code tags added

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Hello and welcome to the Java-Forums! I have added code tags to your post to help make it easier to read. To learn how to do this yourself, please look at the link in my signature.

    As to your problem, I think you're putting the cart before the horse by creating a GUI before you've got your program logic straight. I'd first create an Employee class with fields, constructors, getters and setters; then I'd create a EmployeeData class with an ArrayList<Employee>, and methods to add, edit, search, and remove Employee objects as well as methods for reading and writing the data to a disk file, and then after I've tested and gotten these classes to work would I worry about a GUI to display it all.

    Much luck!

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. search employee id
    By raman_v in forum Java Servlet
    Replies: 2
    Last Post: 12-24-2009, 09:44 AM
  2. Replies: 3
    Last Post: 03-26-2009, 08:35 AM
  3. how to delete record from db using jsp
    By Manas Das in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 01-31-2009, 08:36 PM
  4. Replies: 3
    Last Post: 12-26-2007, 07:42 AM
  5. Doubt in edit and delete methods
    By ai_2007 in forum Advanced Java
    Replies: 3
    Last Post: 07-01-2007, 12:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •