java - Null Pointer Exception in FXML -
so have 1 controller class looks this. isn't whole thing, important part.
in handle button action method, i'm trying input text fields in 1 scene , transfer string , set them on label in scene.
i have code
public class fxmldocumentcontroller implements initializable { @fxml private radiobutton newcustomer; @fxml private radiobutton regularcustomer; @fxml private label total; @fxml private textfield nameinput; @fxml private textfield phonenumberinput; @fxml private textfield emailinput; @fxml private textfield addressinput; @fxml private checkbox brakes; @fxml private checkbox tirerotation; @fxml private checkbox fluidcheck; @fxml private checkbox carwash; @fxml private checkbox inspection; @fxml private checkbox tirereplacement; @fxml private checkbox oilchange; @fxml private combobox<string> tirechoices; @fxml private combobox<string> oilchoices; @fxml private void handlebuttonaction(actionevent event){ try{ stage stage = new stage(); fxmlloader loader = new fxmlloader(); pane root = loader.load(getclass().getresource("invoicewindow.fxml").openstream()); invoicewindowcontroller invoice = (invoicewindowcontroller) loader.getcontroller(); invoice.printcustomerinfo(nameinput.gettext(),phonenumberinput.gettext(),emailinput.gettext(),addressinput.gettext()); scene scene = new scene(root); stage.setscene(scene); stage.show(); }catch(exception e){ } }
and second controller class code looks this
public class invoicewindowcontroller implements initializable { @fxml private label name; @fxml private label phonenumber; @fxml private label email; @fxml private label address; @override public void initialize(url url, resourcebundle rb) { } public void printcustomerinfo(string name, string number, string email, string address){ this.name.settext(name); this.phonenumber.settext(number); this.email.settext(email); this.address.settext(address); } }
i'm receiving null pointer exception at:
invoice.printcustomerinfo(nameinput.gettext(),phonenumberinput.gettext(),emailinput.gettext(),addressinput.gettext());
i assure fx:id correctly assigned.
i checked thousand times. i'm losing mind.
Comments
Post a Comment