how to pass value from textfield to object or file(serializable file)

ive got the layout codes ready(i have 3 classes). after i inputed the first name, last name, address, age and salary then i clicked the button "save", it should save on the Employee.ser file and it should not overwrite every time i save the input information.

Re: how to pass value from textfield to object or file(serializable file)

For starters you need to attach an ActionListener to your 'save' button.
Inside that you can read the fields.
Now that means you have a problem with the fields you have.
You only keep a reference to the last JTextField.
So have a JTextField attribute for all 4 fields, otherwise you won't be able to read the values (easily).

Re: how to pass value from textfield to object or file(serializable file)

Originally Posted by Tolls

For starters you need to attach an ActionListener to your 'save' button.
Inside that you can read the fields.
Now that means you have a problem with the fields you have.
You only keep a reference to the last JTextField.
So have a JTextField attribute for all 4 fields, otherwise you won't be able to read the values (easily).

check my code please, and tell me what i did wrong cuz it still doesnt save on the Employee.ser =/
_________________

Re: how to pass value from textfield to object or file(serializable file)

First, please use [code] tags [/code] when posting code.
That's pretty unreadable as it stands.
Next stick some System.out.println()'s in there so you can see what's going on, as in if the action listener is being called.

Re: how to pass value from textfield to object or file(serializable file)

hmmm... x-x can u tell me a bit more problem and what to do with it. x-x sorry, i really dont know what to do with my code. i havent seen an example on how to transfer textfield from a serializable file. =/

Re: how to pass value from textfield to object or file(serializable file)

Originally Posted by Tolls

First, please use [code] tags [/code] when posting code.
That's pretty unreadable as it stands.
Next stick some System.out.println()'s in there so you can see what's going on, as in if the action listener is being called.

it saves on the employee.ser now but it only save the salary one. hmm.. which part i did wrong? =/