what best way return type popup window. im creating popup window , has fields need filled in. want return type person these fields.
heres call popup window.
button addbutton = new button("add person interested list"); addpersonadop adp = new addpersonadop(); addbutton.setonaction(e -> table.getitems().add(adp.addbuttonperson()));
heres popup window class
public class addpersonadop { private textfield personnameadoption, personaddressadoption, personnoadoption, personemailadoption; public person display() { final stage window = new stage(); borderpane bp = new borderpane(); window.settitle("add person"); button addperson = new button("add selected animal"); addperson.setonaction(e -> { window.close(); addbuttonperson();}); button closebutton = new button("close window"); closebutton.setonaction(e -> window.close()); vbox vbox = new vbox(personfieldsadoption(), addperson, closebutton); vbox.getchildren().addall(); bp.setcenter(vbox); scene scene = new scene(bp, 800,800); window.setscene(scene); window.show(); return addbuttonperson(); } public gridpane personfieldsadoption(){ personnameadoption = new textfield(); personnameadoption.setprompttext("name"); personnameadoption.setminwidth(75); personaddressadoption = new textfield(); personaddressadoption.setprompttext("address"); personaddressadoption.setminwidth(75); personnoadoption = new textfield(); personnoadoption.setprompttext("phone number"); personnoadoption.setminwidth(75); personemailadoption = new textfield(); personemailadoption.setprompttext("email"); personemailadoption.setminwidth(75); gridpane grid = new gridpane(); grid.centershapeproperty(); grid.sethgap(10); grid.setpadding(new insets(10,10,10,10)); grid.addrow(0, customitems.label("enter persons details")); grid.addrow(1, new label("person name *"), new label(" address *"), new label("phone number *"), new label("email *")); grid.addrow(2, personnameadoption, personaddressadoption, personnoadoption, personemailadoption); return grid; } public person addbuttonperson(){ if(personnameadoption.gettext().isempty() || personaddressadoption.gettext().isempty() || personemailadoption.gettext().isempty() || personnoadoption.gettext().isempty()) { alertbox.warn("some person info missing", "please complete person mandatory fields"); person person = new person("name","add","@", "999"); return person; } else{ person person = new person(personnameadoption.gettext(),personaddressadoption.gettext(),personemailadoption.gettext(), personnoadoption.gettext()); return person; } } }
use window.showandwait()
instead of window.show()
in display()
method.
then
addbutton.setonaction(e -> table.getitems().add(adp.display()));
Comments
Post a Comment