java - javafx getting error in string.equals() -
during working on project met problem .
i have added item in combobox:
@fxml private combobox schedule;
i had added value
schedule.getitems().add("create new schedule");
now comparing value:
string p= (string) schedule.getselectionmodel().getselecteditem(); system.out.println(p); if(p.equals("create new schedule")){ system.out.println("got it); }
i getting error on line
if(p.equals("create new schedule")){
error:
exception in thread "javafx application thread" java.lang.runtimeexception: java.lang.reflect.invocationtargetexception @ javafx.fxml.fxmlloader$methodhandler.invoke(fxmlloader.java:1768) @ javafx.fxml.fxmlloader$controllermethodeventhandler.handle(fxmlloader.java:1651) @ com.sun.javafx.event.compositeeventhandler.dispatchbubblingevent(compositeeventhandler.java:86) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:238) null @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:191) @ com.sun.javafx.event.compositeeventdispatcher.dispatchbubblingevent(compositeeventdispatcher.java:59) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:58) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.eventutil.fireeventimpl(eventutil.java:74) @ com.sun.javafx.event.eventutil.fireevent(eventutil.java:49) @ javafx.event.event.fireevent(event.java:204) @ javafx.scene.node.fireevent(node.java:8175) @ javafx.scene.control.comboboxbase.valueinvalidated(comboboxbase.java:136) @ javafx.scene.control.comboboxbase$2.invalidated(comboboxbase.java:161) @ javafx.beans.property.objectpropertybase.markinvalid(objectpropertybase.java:111) @ javafx.beans.property.objectpropertybase.set(objectpropertybase.java:145) @ javafx.scene.control.comboboxbase.setvalue(comboboxbase.java:167) @ com.sun.javafx.scene.control.skin.comboboxlistviewskin.settextfromtextfieldintocomboboxvalue(comboboxlistviewskin.java:512) @ com.sun.javafx.scene.control.skin.comboboxlistviewskin.access$200(comboboxlistviewskin.java:57) @ com.sun.javafx.scene.control.skin.comboboxlistviewskin$6.changed(comboboxlistviewskin.java:416) @ com.sun.javafx.scene.control.skin.comboboxlistviewskin$6.changed(comboboxlistviewskin.java:406) @ com.sun.javafx.binding.expressionhelper$generic.firevaluechangedevent(expressionhelper.java:347) @ com.sun.javafx.binding.expressionhelper.firevaluechangedevent(expressionhelper.java:80) @ javafx.beans.property.readonlybooleanpropertybase.firevaluechangedevent(readonlybooleanpropertybase.java:72) @ javafx.scene.node$focusedproperty.notifylisteners(node.java:7486) @ javafx.scene.node.setfocused(node.java:7537) @ com.sun.javafx.scene.control.skin.comboboxlistviewskin$fakefocustextfield.setfakefocus(comboboxlistviewskin.java:697) @ com.sun.javafx.scene.control.skin.comboboxlistviewskin$2.changed(comboboxlistviewskin.java:145) @ com.sun.javafx.scene.control.skin.comboboxlistviewskin$2.changed(comboboxlistviewskin.java:141) @ com.sun.javafx.binding.expressionhelper$generic.firevaluechangedevent(expressionhelper.java:347) @ com.sun.javafx.binding.expressionhelper.firevaluechangedevent(expressionhelper.java:80) @ javafx.beans.property.readonlybooleanpropertybase.firevaluechangedevent(readonlybooleanpropertybase.java:72) @ javafx.scene.node$focusedproperty.notifylisteners(node.java:7486) @ javafx.scene.node.setfocused(node.java:7537) @ javafx.scene.scene$keyhandler.setwindowfocused(scene.java:3918) @ javafx.scene.scene$keyhandler$1.invalidated(scene.java:3937) @ com.sun.javafx.binding.expressionhelper$singleinvalidation.firevaluechangedevent(expressionhelper.java:135) @ com.sun.javafx.binding.expressionhelper.firevaluechangedevent(expressionhelper.java:80) @ javafx.beans.property.readonlybooleanwrapper$readonlypropertyimpl.firevaluechangedevent(readonlybooleanwrapper.java:178) @ javafx.beans.property.readonlybooleanwrapper$readonlypropertyimpl.access$100(readonlybooleanwrapper.java:148) @ javafx.beans.property.readonlybooleanwrapper.firevaluechangedevent(readonlybooleanwrapper.java:144) @ javafx.beans.property.booleanpropertybase.markinvalid(booleanpropertybase.java:110) @ javafx.beans.property.booleanpropertybase.set(booleanpropertybase.java:143) @ javafx.stage.window.setfocused(window.java:409) @ com.sun.javafx.stage.windowpeerlistener.changedfocused(windowpeerlistener.java:59) @ com.sun.javafx.tk.quantum.glasswindoweventhandler.run(glasswindoweventhandler.java:89) @ com.sun.javafx.tk.quantum.glasswindoweventhandler.run(glasswindoweventhandler.java:39) @ java.security.accesscontroller.doprivileged(native method) @ com.sun.javafx.tk.quantum.glasswindoweventhandler.handlewindowevent(glasswindoweventhandler.java:130) @ com.sun.glass.ui.window.handlewindowevent(window.java:1235) @ com.sun.glass.ui.window.notifyfocus(window.java:1210) @ com.sun.glass.ui.win.winwindow._setvisible(native method) @ com.sun.glass.ui.window.setvisible(window.java:570) @ com.sun.javafx.tk.quantum.windowstage.setvisible(windowstage.java:455) @ javafx.stage.window$9.invalidated(window.java:776) @ javafx.beans.property.booleanpropertybase.markinvalid(booleanpropertybase.java:109) @ javafx.beans.property.booleanpropertybase.set(booleanpropertybase.java:143) @ javafx.stage.window.setshowing(window.java:826) @ javafx.stage.window.hide(window.java:851) @ javafx.stage.stage.close(stage.java:1176) @ schoolmanagement2.dashboardcontroller.close(dashboardcontroller.java:213) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ sun.reflect.misc.trampoline.invoke(methodutil.java:71) @ sun.reflect.generatedmethodaccessor1.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ sun.reflect.misc.methodutil.invoke(methodutil.java:275) @ javafx.fxml.fxmlloader$methodhandler.invoke(fxmlloader.java:1763) @ javafx.fxml.fxmlloader$controllermethodeventhandler.handle(fxmlloader.java:1651) @ com.sun.javafx.event.compositeeventhandler.dispatchbubblingevent(compositeeventhandler.java:86) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:238) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:191) @ com.sun.javafx.event.compositeeventdispatcher.dispatchbubblingevent(compositeeventdispatcher.java:59) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:58) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.eventutil.fireeventimpl(eventutil.java:74) @ com.sun.javafx.event.eventutil.fireevent(eventutil.java:54) @ javafx.event.event.fireevent(event.java:204) @ javafx.scene.scene$clickgenerator.postprocess(scene.java:3456) @ javafx.scene.scene$clickgenerator.access$8300(scene.java:3387) @ javafx.scene.scene$mousehandler.process(scene.java:3755) @ javafx.scene.scene$mousehandler.access$1800(scene.java:3471) @ javafx.scene.scene.impl_processmouseevent(scene.java:1695) @ javafx.scene.scene$scenepeerlistener.mouseevent(scene.java:2486) @ com.sun.javafx.tk.quantum.glassvieweventhandler$mouseeventnotification.run(glassvieweventhandler.java:314) @ com.sun.javafx.tk.quantum.glassvieweventhandler$mouseeventnotification.run(glassvieweventhandler.java:243) @ java.security.accesscontroller.doprivileged(native method) @ com.sun.javafx.tk.quantum.glassvieweventhandler.handlemouseevent(glassvieweventhandler.java:345) @ com.sun.glass.ui.view.handlemouseevent(view.java:526) @ com.sun.glass.ui.view.notifymouse(view.java:898) @ com.sun.glass.ui.win.winapplication._runloop(native method) @ com.sun.glass.ui.win.winapplication.access$300(winapplication.java:39) @ com.sun.glass.ui.win.winapplication$4$1.run(winapplication.java:112) @ java.lang.thread.run(thread.java:745) caused by: java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ sun.reflect.misc.trampoline.invoke(methodutil.java:71) @ sun.reflect.generatedmethodaccessor1.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ sun.reflect.misc.methodutil.invoke(methodutil.java:275) @ javafx.fxml.fxmlloader$methodhandler.invoke(fxmlloader.java:1763) ... 110 more caused by: java.lang.nullpointerexception @ schoolmanagement2.schedulecontroller.schedule(schedulecontroller.java:462)
help me. unable find why got error.
from doc of selectionmodel
's, selecteditem
porperty:
the selected item either null, represent there no selection, or [...]
you can fix code switching sting constant p
:
if("create new schedule".equals(p)){
Comments
Post a Comment