JavaFX ListView选择侦听器问题

时间:2019-03-05 08:25:24

标签: java listview javafx listener

我是Java FX的初学者,并且在使用List View进行更改侦听器时遇到了一些麻烦。我几乎尝试了一切,但没有任何效果。

这是调试器的报告:

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at ukolnicek_mp2.FXMLDocumentController$1.changed(FXMLDocumentController.java:97)
at ukolnicek_mp2.FXMLDocumentController$1.changed(FXMLDocumentController.java:85)
at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:182)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
at javafx.beans.property.ReadOnlyObjectPropertyBase.fireValueChangedEvent(ReadOnlyObjectPropertyBase.java:74)
at javafx.beans.property.ReadOnlyObjectWrapper.fireValueChangedEvent(ReadOnlyObjectWrapper.java:102)
at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
at javafx.scene.control.SelectionModel.setSelectedItem(SelectionModel.java:102)
at javafx.scene.control.MultipleSelectionModelBase.lambda$new$34(MultipleSelectionModelBase.java:67)
at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:137)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
at javafx.beans.property.ReadOnlyIntegerPropertyBase.fireValueChangedEvent(ReadOnlyIntegerPropertyBase.java:72)
at javafx.beans.property.ReadOnlyIntegerWrapper.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:102)
at javafx.beans.property.IntegerPropertyBase.markInvalid(IntegerPropertyBase.java:113)
at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:147)
at javafx.scene.control.SelectionModel.setSelectedIndex(SelectionModel.java:68)
at javafx.scene.control.MultipleSelectionModelBase.select(MultipleSelectionModelBase.java:404)
at ukolnicek_mp2.FXMLDocumentController.initialize(FXMLDocumentController.java:105)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)

完整的错误日志在这里:

https://pastebin.com/raw/Jk5v5XUj

1 个答案:

答案 0 :(得分:0)

该错误是在.fxml文档中。我最近重命名了一个@FXML变量,却忘记了在场景生成器中重新分配它。