【发布时间】:2019-07-26 15:45:21
【问题描述】:
我是 Java FX 的初学者,在使用列表视图更改监听器时遇到了一些麻烦。我几乎尝试了所有方法,但没有任何效果。
这是来自调试器的报告:
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)
完整的错误日志在这里:
【问题讨论】:
-
向我们发送您的代码示例,以便我们更好地理解问题。
-
更具体地说:请提供一个 minimal reproducible example 来证明问题。
-
这里是整个仓库。我不知道问题到底出在哪里,对不起各位:(github.com/vholub/ukolnicek-mp3-git
-
请创建一个MCVE。总而言之,它是一个最小(少量代码)完整(完全可运行)可验证(我可以放入我的 IDE 并在没有预期错误的情况下运行)示例(重新创建您的问题)。
标签: java listview javafx listener