swing - Creating GUI components dynamically in java -


so, can create example button dynamically:

panel.add(new jbutton("button")); validate(); 

but question is, how make calls elements later? example, how add event listener button created above, like, 100 lines of code later?

create variable jbutton:

jbutton jbutton = new jbutton("button"); panel.add(jbutton); validate(); /*  *  * 100 lines of code   *  */  // add event listener jbutton.addactionlistener((actionevent) -> {             //         }); 

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -