java - How to change JButton text in one class based on data from another class? -


background: have accountingmoduleui jframe, has chart of accounts jpanel contains account jbuttons part of arraylist generated through createaccount jbutton, code continuous jbutton generation follows:

private void btncreateaccountactionperformed(java.awt.event.actionevent evt) {                                                      jlabel2.settext("chart of accounts");             buttonarraylist.add(new jbutton("button"+buttoncount));     panelaccounts.add(buttonarraylist.get((buttonarraylist.size()-1)));     buttonarraylist.get((buttonarraylist.size()-1)).show();     buttoncount++;     buttonarraylist.get((buttonarraylist.size()-1)).addactionlistener(new actionlistener(){         public void actionperformed(actionevent e){         inputform.show();         }     });     repaint();     revalidate(); } 

when 1 of newly created jbuttons clicked, input form presented, it's own stand alone class. user enters information , clicks submit button, creates account objects, through following code within inputform class:

private void btnsubmitactionperformed(java.awt.event.actionevent evt) {                                               acctname = txtacctname.gettext();     acctclass = cboxacctclass.getselecteditem().tostring();     acctsubclass = cboxacctsubclass.getselecteditem().tostring();     acctccy = cboxacctccy.getselecteditem().tostring();     accountarraylist.add(new accounts(acctname, acctclass, acctsubclass,(i+1)));     i++;     this.hide(); }            

everything works point, having difficulty trying acctname of account object jbutton text in accountingmoduleui class starting point. suggestions?

look model-view-controller design architecture https://en.wikipedia.org/wiki/model%e2%80%93view%e2%80%93controller

in case have controller class update view in response updates in model. functionality of btnsubmitactionperformed can extended update jbutton new account name.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -