java - Store and Restore previous userinput texfield -


i have 2 textfields can input user , used calculation later (number only), lets inputx , inputy. , 2 radio button, rad1 , rad2.

when user choose rad1, both textfiled input-able user , stored memory/variable when user input in it. when user choose rad2, only inputx available , inputy inputy.settext("inputx only"). if user choose rad1 back, want restore value user input inputy previously, not showing "inputx only".

so, question is: how get previous value userinput when user choose rad1 back, since its has been overridden rad2 inputy.settext("inputx only") ?

please create full code example possible/alternative code, i'm new in java.

note: im using netbeans v8.0.2 , create form using built in form builder/designer

public class inputvalidator extends javax.swing.jframe {  private static final string input_x_only = "inputx only"; private string temp = "";  public inputvalidator() {     initcomponents();     jradiobutton1.setselected(true);     buttongroup1.add(jradiobutton1);     buttongroup1.add(jradiobutton2);      jradiobutton1.addactionlistener(new actionlistener() {          @override         public void actionperformed(actionevent ae) {             jtextfield2.seteditable(true);             jtextfield2.settext(temp);         }     });      jradiobutton2.addactionlistener(new actionlistener() {          @override         public void actionperformed(actionevent ae) {             jtextfield2.seteditable(false);             temp = jtextfield2.gettext();             jtextfield2.settext(input_x_only);         }     }); } 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -