java - NullPointerException with GoogleGuave Event-Bus and JavaFX FXML-UI-Object -
i hope can my, because have no more idea: problem:
if set text of buttons in gui javafx , fxml works fine. if run same function googleguave event-bus returned nullpointer exception.
the example down below show problem: function setlabel() call 2 times. first time function initialize(url arg0, resourcebundle bundle). works, fine , no exception. second time, if event arrived, called listen(localchangeevent event). nullpointer exception comes back.
what reason?
1 package de.iav.bottommenu; import java.io.printwriter; import java.io.stringwriter; 5 import java.net.url; import java.util.resourcebundle; import javafx.fxml.fxml; import javafx.fxml.initializable; 10 import javafx.scene.control.button; import javax.inject.inject; import com.google.common.eventbus.subscribe; import de.iav.events.localchangeevent; 15 public class bottommenupresenter implements initializable { @fxml button b_back, b_next, b_abort; 20 @inject public bottommenuview mainbottommenu; button test; private resourcebundle bundle; 25 // first function in class. call setlabel() , // fine public void initialize(url arg0, resourcebundle bundle) { this.bundle = bundle; 30 this.setlabel(); } public void setlabel() { 35 this.bundle = resourcebundle.getbundle("de.iav.bottommenu.bottommenu"); try{ b_next.settext(bundle.getstring("b_next")); b_back.settext(bundle.getstring("b_back")); 40 b_abort.settext(bundle.getstring("b_abort")); // exception fire only, if call setlabel() // event-bus function,listen(localchangeevent event). }catch(exception e){ 45 system.out.println("fehler: " + e.getmessage()+e.tostring()); stringwriter sw = new stringwriter(); printwriter pw = new printwriter(sw); e.printstacktrace(pw); system.out.println("fullstack: " + sw.tostring()); 50 } } // function called if localchangeevent put // event-bus. function call setlabel() , 55 // exception comes :-( @subscribe public void listen(localchangeevent event) { system.out.println("ich bin im presenter"); setlabel(); 60 }
} lot! bye meho
edit:
java.lang.nullpointerexception @ de.iav.bottommenu.bottommenupresenter.setlabel(bottommenupresenter.java:38) @ de.iav.bottommenu.bottommenupresenter.listen(bottommenupresenter.java:59) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ com.google.common.eventbus.eventsubscriber.handleevent(eventsubscriber.java:74) @ com.google.common.eventbus.synchronizedeventsubscriber.handleevent(synchronizedeventsubscriber.java:47) @ com.google.common.eventbus.eventbus.dispatch(eventbus.java:322) @ com.google.common.eventbus.eventbus.dispatchqueuedevents(eventbus.java:304) @ com.google.common.eventbus.eventbus.post(eventbus.java:275) @ de.iav.language.languagepresenter.changelanguage(languagepresenter.java:68) @ de.iav.language.languagepresenter.b_changelanguageaction(languagepresenter.java:44) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ sun.reflect.misc.trampoline.invoke(unknown source) @ sun.reflect.generatedmethodaccessor1.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ sun.reflect.misc.methodutil.invoke(unknown source) @ javafx.fxml.fxmlloader$methodhandler.invoke(unknown source) @ javafx.fxml.fxmlloader$controllermethodeventhandler.handle(unknown source) @ com.sun.javafx.event.compositeeventhandler.dispatchbubblingevent(unknown source) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(unknown source) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(unknown source) @ com.sun.javafx.event.compositeeventdispatcher.dispatchbubblingevent(unknown source) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(unknown source) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(unknown source) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(unknown source) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(unknown source) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(unknown source) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(unknown source) @ com.sun.javafx.event.eventutil.fireeventimpl(unknown source) @ com.sun.javafx.event.eventutil.fireevent(unknown source) @ javafx.event.event.fireevent(unknown source) @ javafx.scene.node.fireevent(unknown source) @ javafx.scene.control.button.fire(unknown source) @ com.sun.javafx.scene.control.behavior.buttonbehavior.mousereleased(unknown source) @ com.sun.javafx.scene.control.skin.behaviorskinbase$1.handle(unknown source) @ com.sun.javafx.scene.control.skin.behaviorskinbase$1.handle(unknown source) @ com.sun.javafx.event.compositeeventhandler$normaleventhandlerrecord.handlebubblingevent(unknown source) @ com.sun.javafx.event.compositeeventhandler.dispatchbubblingevent(unknown source) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(unknown source) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(unknown source) @ com.sun.javafx.event.compositeeventdispatcher.dispatchbubblingevent(unknown source) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(unknown source) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(unknown source) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(unknown source) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(unknown source) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(unknown source) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(unknown source) @ com.sun.javafx.event.eventutil.fireeventimpl(unknown source) @ com.sun.javafx.event.eventutil.fireevent(unknown source) @ javafx.event.event.fireevent(unknown source) @ javafx.scene.scene$mousehandler.process(unknown source) @ javafx.scene.scene$mousehandler.access$1500(unknown source) @ javafx.scene.scene.impl_processmouseevent(unknown source) @ javafx.scene.scene$scenepeerlistener.mouseevent(unknown source) @ com.sun.javafx.tk.quantum.glassvieweventhandler$mouseeventnotification.run(unknown source) @ com.sun.javafx.tk.quantum.glassvieweventhandler$mouseeventnotification.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ com.sun.javafx.tk.quantum.glassvieweventhandler.lambda$handlemouseevent$350(unknown source) @ com.sun.javafx.tk.quantum.glassvieweventhandler$$lambda$242/1729325342.get(unknown source) @ com.sun.javafx.tk.quantum.quantumtoolkit.runwithoutrenderlock(unknown source) @ com.sun.javafx.tk.quantum.glassvieweventhandler.handlemouseevent(unknown source) @ com.sun.glass.ui.view.handlemouseevent(unknown source) @ com.sun.glass.ui.view.notifymouse(unknown source) @ com.sun.glass.ui.win.winapplication._runloop(native method) @ com.sun.glass.ui.win.winapplication.lambda$null$145(unknown source) @ com.sun.glass.ui.win.winapplication$$lambda$36/2117255219.run(unknown source) @ java.lang.thread.run(unknown source)
Comments
Post a Comment