I have a simple question but I couldn't figure out how to solve it.
It is related to save and get jTextField values, for example:
1. User typed some text on jTextField1 ( for example, "text 1") and clicked Save Button.
2. User cleared "text 1" and typed new text "text 2", but Save Button doesn't clicked.
3. If a user doesn't click Save Button then jTextField1 should return previous value "text1".
I would like to ask how to return previous value of jTextField1 i.e "text 1" when Save Button doesn't hit?
Any help is really appreciated.
Slightly strange requirement. Please explain more. Do you mean are you going to save a snapshot of the program state. Are you going to have a file where you save the contents of the text field? Are you going to restore it from that file? Are you going to save the entire GUI (remember all Swing components count as beans) in XML and restore the state when you open a new GUI?
I have a Content menu with several jPanels (jPanel1, jPanel2), and every jPanel is referenced by CardLayout. Every jPanel has textfields and comboboxes and Save Button. After filling textfields we click save Button, it will save to text file. Also there is have Load Button which loads saved data to textfields. The problem that I am facing is when I modified the text on textfiled (jPanel1) then without clicking Save Button I moved to jPanel2 (CardLayout), and when I return to jPanel1, the modified text on textfield is still shown. I found a solution in combobox case from this link. Similar one I want to implement to textfields too.
That sounds like an implementation detail; you need to explain the concept behind what you are trying to do first. Look at this FAQ. You may to put listeners on the frame which revert the text to its old value whenever that pane is hidden.
If the user action is "moving away from the pane" then, presuming the data is not moved from the GUI to the Model unless Save is clicked, then the issue seems to be not a case of reverting, but a case of populating.
That is, when the user goes to the editing panel then that panel should be populated from the Model and not from whatever data was previously held in the GUI.