我正在尝试在我的ComboBox中添加项目,但是我有以下错误:
Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: Index: 9, Size: 9
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
at com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:306)
at javafx.scene.Parent.layout(Parent.java:1091)
at javafx.scene.Scene.doLayoutPass(Scene.java:552)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2397)
at com.sun.javafx.tk.Toolkit.lambda$runPulse$30(Toolkit.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:354)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:381)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:510)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:490)
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$404(QuantumToolkit.java:319)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)
看到没有错误导致我的实现,只会发生内部错误。 这是我的代码:
irParaCondicao.setOnFinished(event -> {
processos.add(processoEmExecucao.getValue());
processoEmExecucao.set(null);
});
processos.addListener((ListChangeListener<? super Processo>) c -> {
if (c.next()) {
validacaoD.getItems().clear();
validacaoD.getItems().addAll(processosDeD);
}
});
我已经尝试在javafx Thread中使用此代码,但问题无法解决。我也看了IndexOutOfBoundsException while updating a ListView in JavaFX 但没有成功。这只是第一次包容。 有人能帮助我吗?