Válí se ti projekty v šuplíku? Dostaň je mezi lidi a získej cool tričko a body na profi IT kurzy v soutěži ITnetwork summer 2017!
Přidej si svou IT školu do profilu a najdi spolužáky zde na síti :)
Avatar
Vojtěch Janoušek:20.11.2015 14:44

Ahoj, projíždím místní tutoriály a měl bych otázku k tomuhle http://www.itnetwork.cz/…od-do-javafx
Můžete mi někdo, prosím, poradit, jak změnit text na buttonu po stisknutí? Díky

 
Odpovědět 20.11.2015 14:44
Avatar
Tomáš Brůna
Redaktor
Avatar
Odpovídá na Vojtěch Janoušek
Tomáš Brůna:20.11.2015 15:20
public class FXMLDocumentController implements Initializable {



    @FXML
    public Button button;
    public void handleButtonAction() {
           button.setText("lybovolnyText");
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }
Editováno 20.11.2015 15:20
Akceptované řešení
+20 Zkušeností
+1 bodů
Řešení problému
Nahoru Odpovědět 20.11.2015 15:20
Lepší být šprt než blbec :)
Avatar
Odpovídá na Tomáš Brůna
Vojtěch Janoušek:20.11.2015 15:55

Diky za pomoc. Tohle me napadlo. ale nefunguje to.

public class FXMLDocumentController implements Initializable {

    @FXML
    private Label label;
    public Button btn;
    @FXML
    private void handleButtonAction(ActionEvent event) {
        btn.setText("ahoj");
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }
}

vyhodi to chybu

Exception in thread "JavaFX Application Thread" java.lang.Run­timeException: java.lang.reflec­t.InvocationTar­getException
at javafx.fxml.FXMLLo­ader$MethodHan­dler.invoke(FXMLLo­ader.java:1770)
at javafx.fxml.FXMLLo­ader$Controller­MethodEventHan­dler.handle(FXMLLo­ader.java:1653)
at com.sun.javaf­x.event.Compo­siteEventHandler­.dispatchBubblin­gEvent(Composi­teEventHandler­.java:86)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:238)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:191)
at com.sun.javaf­x.event.Compo­siteEventDispat­cher.dispatchBub­blingEvent(Com­positeEventDis­patcher.java:59)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:58)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.EventU­til.fireEventIm­pl(EventUtil.ja­va:74)
at com.sun.javaf­x.event.EventU­til.fireEvent(E­ventUtil.java:49)
at javafx.event.E­vent.fireEven­t(Event.java:198)
at javafx.scene.No­de.fireEvent(No­de.java:8390)
at javafx.scene.con­trol.Button.fi­re(Button.java:185)
at com.sun.javaf­x.scene.control­.behavior.But­tonBehavior.mou­seReleased(But­tonBehavior.ja­va:182)
at com.sun.javaf­x.scene.control­.skin.Behavior­SkinBase$1.han­dle(BehaviorSkin­Base.java:96)
at com.sun.javaf­x.scene.control­.skin.Behavior­SkinBase$1.han­dle(BehaviorSkin­Base.java:89)
at com.sun.javaf­x.event.Compo­siteEventHandler$Nor­malEventHandler­Record.handle­BubblingEvent(Com­positeEventHan­dler.java:218)
at com.sun.javaf­x.event.Compo­siteEventHandler­.dispatchBubblin­gEvent(Composi­teEventHandler­.java:80)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:238)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:191)
at com.sun.javaf­x.event.Compo­siteEventDispat­cher.dispatchBub­blingEvent(Com­positeEventDis­patcher.java:59)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:58)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.EventU­til.fireEventIm­pl(EventUtil.ja­va:74)
at com.sun.javaf­x.event.EventU­til.fireEvent(E­ventUtil.java:54)
at javafx.event.E­vent.fireEven­t(Event.java:198)
at javafx.scene.Sce­ne$MouseHandler­.process(Scene­.java:3758)
at javafx.scene.Sce­ne$MouseHandler­.access$1500(Sce­ne.java:3486)
at javafx.scene.Sce­ne.impl_proces­sMouseEvent(Sce­ne.java:1762)
at javafx.scene.Sce­ne$ScenePeerLis­tener.mouseEven­t(Scene.java:2495)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$MouseEven­tNotification­.run(GlassVie­wEventHandler­.java:350)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$MouseEven­tNotification­.run(GlassVie­wEventHandler­.java:275)
at java.security­.AccessContro­ller.doPrivile­ged(Native Method)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler.lambda$han­dleMouseEvent$350(Glas­sViewEventHan­dler.java:385)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$$Lambda$113/2083­713813.get(Un­known Source)
at com.sun.javaf­x.tk.quantum.Qu­antumToolkit.run­WithoutRender­Lock(QuantumTo­olkit.java:404)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler.handleMou­seEvent(GlassVi­ewEventHandler­.java:384)
at com.sun.glass­.ui.View.handle­MouseEvent(Vi­ew.java:555)
at com.sun.glass­.ui.View.noti­fyMouse(View.ja­va:927)
at com.sun.glass­.ui.win.WinAp­plication._run­Loop(Native Method)
at com.sun.glass­.ui.win.WinAp­plication.lam­bda$null$145(Wi­nApplication.ja­va:101)
at com.sun.glass­.ui.win.WinAp­plication$$Lam­bda$36/1963387170­.run(Unknown Source)
at java.lang.Thre­ad.run(Thread­.java:745)
Caused by: java.lang.reflec­t.InvocationTar­getException
at sun.reflect.Na­tiveMethodAcces­sorImpl.invoke0(Na­tive Method)
at sun.reflect.Na­tiveMethodAcces­sorImpl.invoke(Na­tiveMethodAcces­sorImpl.java:62)
at sun.reflect.De­legatingMetho­dAccessorImpl­.invoke(Delega­tingMethodAcces­sorImpl.java:43)
at java.lang.reflec­t.Method.invo­ke(Method.java:497)
at sun.reflect.mis­c.Trampoline.in­voke(MethodUtil­.java:71)
at sun.reflect.Ge­neratedMethodAc­cessor1.invoke(Un­known Source)
at sun.reflect.De­legatingMetho­dAccessorImpl­.invoke(Delega­tingMethodAcces­sorImpl.java:43)
at java.lang.reflec­t.Method.invo­ke(Method.java:497)
at sun.reflect.mis­c.MethodUtil.in­voke(MethodUtil­.java:275)
at javafx.fxml.FXMLLo­ader$MethodHan­dler.invoke(FXMLLo­ader.java:1765)
... 50 more
Caused by: java.lang.NullPo­interException
at hallofx.FXMLDo­cumentController­.handleButtonAc­tion(FXMLDocu­mentController­.java:27)
... 60 more
Exception in thread "JavaFX Application Thread" java.lang.Run­timeException: java.lang.reflec­t.InvocationTar­getException
at javafx.fxml.FXMLLo­ader$MethodHan­dler.invoke(FXMLLo­ader.java:1770)
at javafx.fxml.FXMLLo­ader$Controller­MethodEventHan­dler.handle(FXMLLo­ader.java:1653)
at com.sun.javaf­x.event.Compo­siteEventHandler­.dispatchBubblin­gEvent(Composi­teEventHandler­.java:86)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:238)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:191)
at com.sun.javaf­x.event.Compo­siteEventDispat­cher.dispatchBub­blingEvent(Com­positeEventDis­patcher.java:59)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:58)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.EventU­til.fireEventIm­pl(EventUtil.ja­va:74)
at com.sun.javaf­x.event.EventU­til.fireEvent(E­ventUtil.java:49)
at javafx.event.E­vent.fireEven­t(Event.java:198)
at javafx.scene.No­de.fireEvent(No­de.java:8390)
at javafx.scene.con­trol.Button.fi­re(Button.java:185)
at com.sun.javaf­x.scene.control­.behavior.But­tonBehavior.mou­seReleased(But­tonBehavior.ja­va:182)
at com.sun.javaf­x.scene.control­.skin.Behavior­SkinBase$1.han­dle(BehaviorSkin­Base.java:96)
at com.sun.javaf­x.scene.control­.skin.Behavior­SkinBase$1.han­dle(BehaviorSkin­Base.java:89)
at com.sun.javaf­x.event.Compo­siteEventHandler$Nor­malEventHandler­Record.handle­BubblingEvent(Com­positeEventHan­dler.java:218)
at com.sun.javaf­x.event.Compo­siteEventHandler­.dispatchBubblin­gEvent(Composi­teEventHandler­.java:80)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:238)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:191)
at com.sun.javaf­x.event.Compo­siteEventDispat­cher.dispatchBub­blingEvent(Com­positeEventDis­patcher.java:59)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:58)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.EventU­til.fireEventIm­pl(EventUtil.ja­va:74)
at com.sun.javaf­x.event.EventU­til.fireEvent(E­ventUtil.java:54)
at javafx.event.E­vent.fireEven­t(Event.java:198)
at javafx.scene.Sce­ne$MouseHandler­.process(Scene­.java:3758)
at javafx.scene.Sce­ne$MouseHandler­.access$1500(Sce­ne.java:3486)
at javafx.scene.Sce­ne.impl_proces­sMouseEvent(Sce­ne.java:1762)
at javafx.scene.Sce­ne$ScenePeerLis­tener.mouseEven­t(Scene.java:2495)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$MouseEven­tNotification­.run(GlassVie­wEventHandler­.java:350)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$MouseEven­tNotification­.run(GlassVie­wEventHandler­.java:275)
at java.security­.AccessContro­ller.doPrivile­ged(Native Method)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler.lambda$han­dleMouseEvent$350(Glas­sViewEventHan­dler.java:385)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$$Lambda$113/2083­713813.get(Un­known Source)
at com.sun.javaf­x.tk.quantum.Qu­antumToolkit.run­WithoutRender­Lock(QuantumTo­olkit.java:404)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler.handleMou­seEvent(GlassVi­ewEventHandler­.java:384)
at com.sun.glass­.ui.View.handle­MouseEvent(Vi­ew.java:555)
at com.sun.glass­.ui.View.noti­fyMouse(View.ja­va:927)
at com.sun.glass­.ui.win.WinAp­plication._run­Loop(Native Method)
at com.sun.glass­.ui.win.WinAp­plication.lam­bda$null$145(Wi­nApplication.ja­va:101)
at com.sun.glass­.ui.win.WinAp­plication$$Lam­bda$36/1963387170­.run(Unknown Source)
at java.lang.Thre­ad.run(Thread­.java:745)
Caused by: java.lang.reflec­t.InvocationTar­getException
at sun.reflect.Na­tiveMethodAcces­sorImpl.invoke0(Na­tive Method)
at sun.reflect.Na­tiveMethodAcces­sorImpl.invoke(Na­tiveMethodAcces­sorImpl.java:62)
at sun.reflect.De­legatingMetho­dAccessorImpl­.invoke(Delega­tingMethodAcces­sorImpl.java:43)
at java.lang.reflec­t.Method.invo­ke(Method.java:497)
at sun.reflect.mis­c.Trampoline.in­voke(MethodUtil­.java:71)
at sun.reflect.Ge­neratedMethodAc­cessor1.invoke(Un­known Source)
at sun.reflect.De­legatingMetho­dAccessorImpl­.invoke(Delega­tingMethodAcces­sorImpl.java:43)
at java.lang.reflec­t.Method.invo­ke(Method.java:497)
at sun.reflect.mis­c.MethodUtil.in­voke(MethodUtil­.java:275)
at javafx.fxml.FXMLLo­ader$MethodHan­dler.invoke(FXMLLo­ader.java:1765)
... 50 more
Caused by: java.lang.NullPo­interException
at hallofx.FXMLDo­cumentController­.handleButtonAc­tion(FXMLDocu­mentController­.java:27)
... 60 more
Exception in thread "JavaFX Application Thread" java.lang.Run­timeException: java.lang.reflec­t.InvocationTar­getException
at javafx.fxml.FXMLLo­ader$MethodHan­dler.invoke(FXMLLo­ader.java:1770)
at javafx.fxml.FXMLLo­ader$Controller­MethodEventHan­dler.handle(FXMLLo­ader.java:1653)
at com.sun.javaf­x.event.Compo­siteEventHandler­.dispatchBubblin­gEvent(Composi­teEventHandler­.java:86)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:238)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:191)
at com.sun.javaf­x.event.Compo­siteEventDispat­cher.dispatchBub­blingEvent(Com­positeEventDis­patcher.java:59)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:58)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.EventU­til.fireEventIm­pl(EventUtil.ja­va:74)
at com.sun.javaf­x.event.EventU­til.fireEvent(E­ventUtil.java:49)
at javafx.event.E­vent.fireEven­t(Event.java:198)
at javafx.scene.No­de.fireEvent(No­de.java:8390)
at javafx.scene.con­trol.Button.fi­re(Button.java:185)
at com.sun.javaf­x.scene.control­.behavior.But­tonBehavior.mou­seReleased(But­tonBehavior.ja­va:182)
at com.sun.javaf­x.scene.control­.skin.Behavior­SkinBase$1.han­dle(BehaviorSkin­Base.java:96)
at com.sun.javaf­x.scene.control­.skin.Behavior­SkinBase$1.han­dle(BehaviorSkin­Base.java:89)
at com.sun.javaf­x.event.Compo­siteEventHandler$Nor­malEventHandler­Record.handle­BubblingEvent(Com­positeEventHan­dler.java:218)
at com.sun.javaf­x.event.Compo­siteEventHandler­.dispatchBubblin­gEvent(Composi­teEventHandler­.java:80)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:238)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:191)
at com.sun.javaf­x.event.Compo­siteEventDispat­cher.dispatchBub­blingEvent(Com­positeEventDis­patcher.java:59)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:58)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.EventU­til.fireEventIm­pl(EventUtil.ja­va:74)
at com.sun.javaf­x.event.EventU­til.fireEvent(E­ventUtil.java:54)
at javafx.event.E­vent.fireEven­t(Event.java:198)
at javafx.scene.Sce­ne$MouseHandler­.process(Scene­.java:3758)
at javafx.scene.Sce­ne$MouseHandler­.access$1500(Sce­ne.java:3486)
at javafx.scene.Sce­ne.impl_proces­sMouseEvent(Sce­ne.java:1762)
at javafx.scene.Sce­ne$ScenePeerLis­tener.mouseEven­t(Scene.java:2495)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$MouseEven­tNotification­.run(GlassVie­wEventHandler­.java:350)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$MouseEven­tNotification­.run(GlassVie­wEventHandler­.java:275)
at java.security­.AccessContro­ller.doPrivile­ged(Native Method)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler.lambda$han­dleMouseEvent$350(Glas­sViewEventHan­dler.java:385)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$$Lambda$113/2083­713813.get(Un­known Source)
at com.sun.javaf­x.tk.quantum.Qu­antumToolkit.run­WithoutRender­Lock(QuantumTo­olkit.java:404)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler.handleMou­seEvent(GlassVi­ewEventHandler­.java:384)
at com.sun.glass­.ui.View.handle­MouseEvent(Vi­ew.java:555)
at com.sun.glass­.ui.View.noti­fyMouse(View.ja­va:927)
at com.sun.glass­.ui.win.WinAp­plication._run­Loop(Native Method)
at com.sun.glass­.ui.win.WinAp­plication.lam­bda$null$145(Wi­nApplication.ja­va:101)
at com.sun.glass­.ui.win.WinAp­plication$$Lam­bda$36/1963387170­.run(Unknown Source)
at java.lang.Thre­ad.run(Thread­.java:745)
Caused by: java.lang.reflec­t.InvocationTar­getException
at sun.reflect.Na­tiveMethodAcces­sorImpl.invoke0(Na­tive Method)
at sun.reflect.Na­tiveMethodAcces­sorImpl.invoke(Na­tiveMethodAcces­sorImpl.java:62)
at sun.reflect.De­legatingMetho­dAccessorImpl­.invoke(Delega­tingMethodAcces­sorImpl.java:43)
at java.lang.reflec­t.Method.invo­ke(Method.java:497)
at sun.reflect.mis­c.Trampoline.in­voke(MethodUtil­.java:71)
at sun.reflect.Ge­neratedMethodAc­cessor1.invoke(Un­known Source)
at sun.reflect.De­legatingMetho­dAccessorImpl­.invoke(Delega­tingMethodAcces­sorImpl.java:43)
at java.lang.reflec­t.Method.invo­ke(Method.java:497)
at sun.reflect.mis­c.MethodUtil.in­voke(MethodUtil­.java:275)
at javafx.fxml.FXMLLo­ader$MethodHan­dler.invoke(FXMLLo­ader.java:1765)
... 50 more
Caused by: java.lang.NullPo­interException
at hallofx.FXMLDo­cumentController­.handleButtonAc­tion(FXMLDocu­mentController­.java:27)
... 60 more
Exception in thread "JavaFX Application Thread" java.lang.Run­timeException: java.lang.reflec­t.InvocationTar­getException
at javafx.fxml.FXMLLo­ader$MethodHan­dler.invoke(FXMLLo­ader.java:1770)
at javafx.fxml.FXMLLo­ader$Controller­MethodEventHan­dler.handle(FXMLLo­ader.java:1653)
at com.sun.javaf­x.event.Compo­siteEventHandler­.dispatchBubblin­gEvent(Composi­teEventHandler­.java:86)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:238)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:191)
at com.sun.javaf­x.event.Compo­siteEventDispat­cher.dispatchBub­blingEvent(Com­positeEventDis­patcher.java:59)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:58)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.EventU­til.fireEventIm­pl(EventUtil.ja­va:74)
at com.sun.javaf­x.event.EventU­til.fireEvent(E­ventUtil.java:49)
at javafx.event.E­vent.fireEven­t(Event.java:198)
at javafx.scene.No­de.fireEvent(No­de.java:8390)
at javafx.scene.con­trol.Button.fi­re(Button.java:185)
at com.sun.javaf­x.scene.control­.behavior.But­tonBehavior.mou­seReleased(But­tonBehavior.ja­va:182)
at com.sun.javaf­x.scene.control­.skin.Behavior­SkinBase$1.han­dle(BehaviorSkin­Base.java:96)
at com.sun.javaf­x.scene.control­.skin.Behavior­SkinBase$1.han­dle(BehaviorSkin­Base.java:89)
at com.sun.javaf­x.event.Compo­siteEventHandler$Nor­malEventHandler­Record.handle­BubblingEvent(Com­positeEventHan­dler.java:218)
at com.sun.javaf­x.event.Compo­siteEventHandler­.dispatchBubblin­gEvent(Composi­teEventHandler­.java:80)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:238)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:191)
at com.sun.javaf­x.event.Compo­siteEventDispat­cher.dispatchBub­blingEvent(Com­positeEventDis­patcher.java:59)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:58)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.EventU­til.fireEventIm­pl(EventUtil.ja­va:74)
at com.sun.javaf­x.event.EventU­til.fireEvent(E­ventUtil.java:54)
at javafx.event.E­vent.fireEven­t(Event.java:198)
at javafx.scene.Sce­ne$MouseHandler­.process(Scene­.java:3758)
at javafx.scene.Sce­ne$MouseHandler­.access$1500(Sce­ne.java:3486)
at javafx.scene.Sce­ne.impl_proces­sMouseEvent(Sce­ne.java:1762)
at javafx.scene.Sce­ne$ScenePeerLis­tener.mouseEven­t(Scene.java:2495)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$MouseEven­tNotification­.run(GlassVie­wEventHandler­.java:350)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$MouseEven­tNotification­.run(GlassVie­wEventHandler­.java:275)
at java.security­.AccessContro­ller.doPrivile­ged(Native Method)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler.lambda$han­dleMouseEvent$350(Glas­sViewEventHan­dler.java:385)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$$Lambda$113/2083­713813.get(Un­known Source)
at com.sun.javaf­x.tk.quantum.Qu­antumToolkit.run­WithoutRender­Lock(QuantumTo­olkit.java:404)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler.handleMou­seEvent(GlassVi­ewEventHandler­.java:384)
at com.sun.glass­.ui.View.handle­MouseEvent(Vi­ew.java:555)
at com.sun.glass­.ui.View.noti­fyMouse(View.ja­va:927)
at com.sun.glass­.ui.win.WinAp­plication._run­Loop(Native Method)
at com.sun.glass­.ui.win.WinAp­plication.lam­bda$null$145(Wi­nApplication.ja­va:101)
at com.sun.glass­.ui.win.WinAp­plication$$Lam­bda$36/1963387170­.run(Unknown Source)
at java.lang.Thre­ad.run(Thread­.java:745)
Caused by: java.lang.reflec­t.InvocationTar­getException
at sun.reflect.Na­tiveMethodAcces­sorImpl.invoke0(Na­tive Method)
at sun.reflect.Na­tiveMethodAcces­sorImpl.invoke(Na­tiveMethodAcces­sorImpl.java:62)
at sun.reflect.De­legatingMetho­dAccessorImpl­.invoke(Delega­tingMethodAcces­sorImpl.java:43)
at java.lang.reflec­t.Method.invo­ke(Method.java:497)
at sun.reflect.mis­c.Trampoline.in­voke(MethodUtil­.java:71)
at sun.reflect.Ge­neratedMethodAc­cessor1.invoke(Un­known Source)
at sun.reflect.De­legatingMetho­dAccessorImpl­.invoke(Delega­tingMethodAcces­sorImpl.java:43)
at java.lang.reflec­t.Method.invo­ke(Method.java:497)
at sun.reflect.mis­c.MethodUtil.in­voke(MethodUtil­.java:275)
at javafx.fxml.FXMLLo­ader$MethodHan­dler.invoke(FXMLLo­ader.java:1765)
... 50 more
Caused by: java.lang.NullPo­interException
at hallofx.FXMLDo­cumentController­.handleButtonAc­tion(FXMLDocu­mentController­.java:27)
... 60 more
Exception in thread "JavaFX Application Thread" java.lang.Run­timeException: java.lang.reflec­t.InvocationTar­getException
at javafx.fxml.FXMLLo­ader$MethodHan­dler.invoke(FXMLLo­ader.java:1770)
at javafx.fxml.FXMLLo­ader$Controller­MethodEventHan­dler.handle(FXMLLo­ader.java:1653)
at com.sun.javaf­x.event.Compo­siteEventHandler­.dispatchBubblin­gEvent(Composi­teEventHandler­.java:86)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:238)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:191)
at com.sun.javaf­x.event.Compo­siteEventDispat­cher.dispatchBub­blingEvent(Com­positeEventDis­patcher.java:59)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:58)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.EventU­til.fireEventIm­pl(EventUtil.ja­va:74)
at com.sun.javaf­x.event.EventU­til.fireEvent(E­ventUtil.java:49)
at javafx.event.E­vent.fireEven­t(Event.java:198)
at javafx.scene.No­de.fireEvent(No­de.java:8390)
at javafx.scene.con­trol.Button.fi­re(Button.java:185)
at com.sun.javaf­x.scene.control­.behavior.But­tonBehavior.mou­seReleased(But­tonBehavior.ja­va:182)
at com.sun.javaf­x.scene.control­.skin.Behavior­SkinBase$1.han­dle(BehaviorSkin­Base.java:96)
at com.sun.javaf­x.scene.control­.skin.Behavior­SkinBase$1.han­dle(BehaviorSkin­Base.java:89)
at com.sun.javaf­x.event.Compo­siteEventHandler$Nor­malEventHandler­Record.handle­BubblingEvent(Com­positeEventHan­dler.java:218)
at com.sun.javaf­x.event.Compo­siteEventHandler­.dispatchBubblin­gEvent(Composi­teEventHandler­.java:80)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:238)
at com.sun.javaf­x.event.EventHan­dlerManager.dis­patchBubblingE­vent(EventHan­dlerManager.ja­va:191)
at com.sun.javaf­x.event.Compo­siteEventDispat­cher.dispatchBub­blingEvent(Com­positeEventDis­patcher.java:59)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:58)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.BasicE­ventDispatcher­.dispatchEven­t(BasicEventDis­patcher.java:56)
at com.sun.javaf­x.event.EventDis­patchChainImpl­.dispatchEven­t(EventDispat­chChainImpl.ja­va:114)
at com.sun.javaf­x.event.EventU­til.fireEventIm­pl(EventUtil.ja­va:74)
at com.sun.javaf­x.event.EventU­til.fireEvent(E­ventUtil.java:54)
at javafx.event.E­vent.fireEven­t(Event.java:198)
at javafx.scene.Sce­ne$MouseHandler­.process(Scene­.java:3758)
at javafx.scene.Sce­ne$MouseHandler­.access$1500(Sce­ne.java:3486)
at javafx.scene.Sce­ne.impl_proces­sMouseEvent(Sce­ne.java:1762)
at javafx.scene.Sce­ne$ScenePeerLis­tener.mouseEven­t(Scene.java:2495)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$MouseEven­tNotification­.run(GlassVie­wEventHandler­.java:350)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$MouseEven­tNotification­.run(GlassVie­wEventHandler­.java:275)
at java.security­.AccessContro­ller.doPrivile­ged(Native Method)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler.lambda$han­dleMouseEvent$350(Glas­sViewEventHan­dler.java:385)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler$$Lambda$113/2083­713813.get(Un­known Source)
at com.sun.javaf­x.tk.quantum.Qu­antumToolkit.run­WithoutRender­Lock(QuantumTo­olkit.java:404)
at com.sun.javaf­x.tk.quantum.Glas­sViewEventHan­dler.handleMou­seEvent(GlassVi­ewEventHandler­.java:384)
at com.sun.glass­.ui.View.handle­MouseEvent(Vi­ew.java:555)
at com.sun.glass­.ui.View.noti­fyMouse(View.ja­va:927)
at com.sun.glass­.ui.win.WinAp­plication._run­Loop(Native Method)
at com.sun.glass­.ui.win.WinAp­plication.lam­bda$null$145(Wi­nApplication.ja­va:101)
at com.sun.glass­.ui.win.WinAp­plication$$Lam­bda$36/1963387170­.run(Unknown Source)
at java.lang.Thre­ad.run(Thread­.java:745)
Caused by: java.lang.reflec­t.InvocationTar­getException
at sun.reflect.Na­tiveMethodAcces­sorImpl.invoke0(Na­tive Method)
at sun.reflect.Na­tiveMethodAcces­sorImpl.invoke(Na­tiveMethodAcces­sorImpl.java:62)
at sun.reflect.De­legatingMetho­dAccessorImpl­.invoke(Delega­tingMethodAcces­sorImpl.java:43)
at java.lang.reflec­t.Method.invo­ke(Method.java:497)
at sun.reflect.mis­c.Trampoline.in­voke(MethodUtil­.java:71)
at sun.reflect.Ge­neratedMethodAc­cessor1.invoke(Un­known Source)
at sun.reflect.De­legatingMetho­dAccessorImpl­.invoke(Delega­tingMethodAcces­sorImpl.java:43)
at java.lang.reflec­t.Method.invo­ke(Method.java:497)
at sun.reflect.mis­c.MethodUtil.in­voke(MethodUtil­.java:275)
at javafx.fxml.FXMLLo­ader$MethodHan­dler.invoke(FXMLLo­ader.java:1765)
... 50 more
Caused by: java.lang.NullPo­interException
at hallofx.FXMLDo­cumentController­.handleButtonAc­tion(FXMLDocu­mentController­.java:27)
... 60 more

 
Nahoru Odpovědět 20.11.2015 15:55
Avatar
Tomáš Brůna
Redaktor
Avatar
Odpovídá na Vojtěch Janoušek
Tomáš Brůna:20.11.2015 16:10

Můžeš mi prosím poslat tvůj návrhář?

Nahoru Odpovědět 20.11.2015 16:10
Lepší být šprt než blbec :)
Avatar
Vojtěch Janoušek:20.11.2015 16:35

Prosim te promin, Moje chyba - pojmenovani promennych to moje smrt

 
Nahoru Odpovědět 20.11.2015 16:35
Avatar
Tomáš Brůna
Redaktor
Avatar
Odpovídá na Vojtěch Janoušek
Tomáš Brůna:20.11.2015 16:37

V pohodě ;), to znám :D

Nahoru Odpovědět 20.11.2015 16:37
Lepší být šprt než blbec :)
Avatar
Odpovídá na Vojtěch Janoušek
Petr Štechmüller:20.11.2015 16:40

Vždyť ta chyba Ti píše, co je špatně

Caused by: java.lang.NullPointerException

To znamená, ze proměnná btn je null. Musís ji sparovat ve fxml souboru.

Nahoru Odpovědět 20.11.2015 16:40
Pokud spolu kód a komentář nekorespondují, budou patrně oba chybné
Avatar
Tomáš Brůna
Redaktor
Avatar
Odpovídá na Petr Štechmüller
Tomáš Brůna:20.11.2015 16:54

Myslím že to jenom napsal trochu jinak než to myslel :)

Nahoru Odpovědět 20.11.2015 16:54
Lepší být šprt než blbec :)
Avatar
Odpovídá na Tomáš Brůna
Petr Štechmüller:20.11.2015 17:06

Mohl to psát jakkoliv, ale důvod výjimky se nemění.

Nahoru Odpovědět 20.11.2015 17:06
Pokud spolu kód a komentář nekorespondují, budou patrně oba chybné
Avatar
Tomáš Brůna
Redaktor
Avatar
Odpovídá na Petr Štechmüller
Tomáš Brůna:20.11.2015 17:08

To je pravda

Editováno 20.11.2015 17:09
Nahoru Odpovědět 20.11.2015 17:08
Lepší být šprt než blbec :)
Avatar
Richard H.
Redaktor
Avatar
Odpovídá na Petr Štechmüller
Richard H.:23.11.2015 19:44

Vím kde je chyba

public class FXMLDocumentController implements Initializable {

    @FXML
    private Label label;
   @FXML
    public Button btn;
    @FXML
    private void handleButtonAction(ActionEvent event) {
        btn.setText("ahoj");
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }
}

Jednoduše si btn zampoměl anotovat jako @FXML takže ho JavaFX nenašla.

Nahoru Odpovědět  +1 23.11.2015 19:44
Malý užitečný manuál je vždy lepší než bichle k ničemu.
Avatar
Odpovídá na Richard H.
Petr Štechmüller:23.11.2015 20:01

Pokud mas btn public, tak to anotaci nepotřebuje. Musí tam být pouze, pokud je to private.

Nahoru Odpovědět 23.11.2015 20:01
Pokud spolu kód a komentář nekorespondují, budou patrně oba chybné
Avatar
Richard H.
Redaktor
Avatar
Odpovídá na Petr Štechmüller
Richard H.:24.11.2015 18:52

A to si jako čet kde ?

Nahoru Odpovědět 24.11.2015 18:52
Malý užitečný manuál je vždy lepší než bichle k ničemu.
Avatar
Odpovídá na Richard H.
Petr Štechmüller:24.11.2015 19:44

Mam to ozkoušený :)

Nahoru Odpovědět  +1 24.11.2015 19:44
Pokud spolu kód a komentář nekorespondují, budou patrně oba chybné
Avatar
Richard H.
Redaktor
Avatar
Nahoru Odpovědět 24.11.2015 19:55
Malý užitečný manuál je vždy lepší než bichle k ničemu.
Děláme co je v našich silách, aby byly zdejší diskuze co nejkvalitnější. Proto do nich také mohou přispívat pouze registrovaní členové. Pro zapojení do diskuze se přihlas. Pokud ještě nemáš účet, zaregistruj se, je to zdarma.

Zobrazeno 15 zpráv z 15.