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
Post a Comment