java - How do I read the information of a JTextField from a separate class using an ActionListener -


the following code within class has buttons , checkboxes defined. problem having lines "string text = txtfield.gettext();" , "chkaccount.withdraw(amount);".

i have separate class file defines txtfield , trying text has been input box. error see "cannot find symbol". have looked cant find information in depth enough answer question.

the second line refers object chkaccount derived separate class "account" , instantiated in main class of program. error same above.

//button listeners class     withdrawalbtn.addactionlistener(new actionlistener() {         public void actionperformed(actionevent e) {             //execute code when button pressed             if(checking.isselected()) {                 string text = txtfield.gettext();                 int amount = integer.parseint(text);                 try {                     chkaccount.withdraw(amount);                 } catch (insufficientfunds ex) {                     int messagetype = joptionpane.plain_message;                     joptionpane.showmessagedialog(null, "balance low" +                             "or amount entered not interval of 20.",                              "notice", messagetype);                 }                 } 

i can't tell code you've provided trying do, based on title of question, recommend have class want information go extends actionlistener, add object of type of class (the 1 had extend actionlistener) actionlistener jtextfield, , in actionperformed method (which you'll have add, class extends actionlistener) use actionevent.getsource (and cast) jtextfield! there, can extract information need.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -