java - fxml getTitle method can't be interpreted by FXMLLoader -
i have problem fxml code. want string of stage title when initialize it, when try call operation stage.gettitle()
fxmlloader throws exception. tried title within other methods worked in of them. can tell me problem right there?
this stage initialized:
@fxml private void handlemodellaction(actionevent event) throws ioexception{ fxmlloader load = new fxmlloader(getclass().getresource("inex.fxml")); parent root = (parent) load.load(); stage stage = new stage(); stage.setscene(new scene(root)); stage.show(); link = (hyperlink) event.gettarget(); model = link.gettext(); stage.settitle(model); }
this initialize method in controller class:
public void gettitle(){ system.out.println(this.stage.gettitle()); } @override public void initialize(url url, resourcebundle rb) { image = new image("images/test.png", 1500, 900, true, true); interieurimg.setimage(image); model = this.stage.gettitle(); }
this exception thrown:
exception in thread "javafx application thread" java.lang.runtimeexception: java.lang.reflect.invocationtargetexception @ javafx.fxml.fxmlloader$methodhandler.invoke(fxmlloader.java:1774) @ javafx.fxml.fxmlloader$controllermethodeventhandler.handle(fxmlloader.java:1657) @ com.sun.javafx.event.compositeeventhandler.dispatchbubblingevent(compositeeventhandler.java:86) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:238) ... 52 more caused by: javafx.fxml.loadexception: file:/c:/users/p356545/documents/netbeansprojects/vfafxml3/dist/run1293777989/vfafxml3.jar!/vfafxml3/interieur.fxml @ javafx.fxml.fxmlloader.constructloadexception(fxmlloader.java:2601) @ javafx.fxml.fxmlloader.loadimpl(fxmlloader.java:2579) @ ... @ vfafxml3.inexcontroller.handleinterieuraction(inexcontroller.java:58) ... 62 more caused by: java.lang.nullpointerexception @ vfafxml3.interieurcontroller.gettitle(interieurcontroller.java:49) @ vfafxml3.interieurcontroller.initialize(interieurcontroller.java:88) @ javafx.fxml.fxmlloader.loadimpl(fxmlloader.java:2548) ... 70 more
it stage title in initialize-method. can in other method after stage initialized following implementation:
public string gettitle(){ stage stages = (stage) anychoosenelement.getscene().getwindow(); string modelstring = stages.gettitle(); return modelstring; }
Comments
Post a Comment