I asynchronously prepare wizard and when ready I Dock it to a workspace. however I have some strange problem when trying to add second step - when I am using wizard with single step everything is working fine, the problem arises only when I wan to add a second one - it gives error posted below.
What is funny Although I get the error, the program seems to work fine when I only close the error window and both steps are added to Wizard and working
Invoking Wizard
val bigTarczycaWiztoList: Deferred<bigTarczycaWizard> = async{ bigTarczycaWizard( ) }
init {
bigTarczycaWiztoList.invokeOnCompletion {
async{ bigTarczycaWiztoList.await().controlleerr =bigTarczycaController() }
}}
fun bigTarczycaWizDock() {
if(bigTarczycaWiztoList.isCompleted) { workspace.dock(bigTarczycaWiztoList.getCompleted(), true)
} else {
bigTarczycaWiztoList.invokeOnCompletion {workspace.dock(bigTarczycaWiztoList.getCompleted(), true) }
}
}
Wizard
class bigTarczycaWizard () : MyWizard("Tarczyca Tc", "Opis Badania") {
init {
graphic = imageview("graphics/Webp.net-resizeimage.jpg")
add(bigTarczycaStep1():: class)
add(bigTarczycaStep2() :: class)
} }
Error
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
at java.util.AbstractList.rangeCheckForAdd(AbstractList.java:605)
at java.util.AbstractList.addAll(AbstractList.java:257)
at javafx.collections.ModifiableObservableListBase.addAll(ModifiableObservableListBase.java:110)
at com.sun.javafx.collections.VetoableListDecorator.addAll(VetoableListDecorator.java:252)
at tornadofx.ListConversionListener.onChanged(Collections.kt:231)
at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
at javafx.collections.ModifiableObservableListBase.add(ModifiableObservableListBase.java:155)
at java.util.AbstractList.add(AbstractList.java:108)
at tornadofx.FXKt.addChildIfPossible(FX.kt:494)
at tornadofx.FXKt.addChildIfPossible$default(FX.kt:454)
at tornadofx.NodesKt.plusAssign(Nodes.kt:228)
at tornadofx.UIComponent.add(Component.kt:685)
at tornadofx.UIComponent.add$default(Component.kt:683)
at implementation.BigFragControllers.bigTarczycaWizard.<init>(bigTarczycaController.kt:159)
at implementation.menu.MenuControllersList$bigTarczycaWiztoList$1.doResume(MenuControllersList.kt:15)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:54)
at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:161)
at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:25)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
I haven't look at your code, but JavaFX components _must_ be created on the UI thread. You simply can't create them on a background thread, so I suspect this is what's causing the error. Please confirm :)
Thank You for fast response, Hovewer in this case I suppose hat it is not a problem because
1) It would give the same error when I am adding Wizard with only one step - and It is not the case - until I have one step wizard everything works fine
2) It will not only cause error, but this error would break a program - and It did not happene also - Error appears but , just after shutting down window with error stacktrace I have a working application with docked wizard with 2 steps. Although maybe I have not spotted some component that is not working.
Can you supply some demo code which exhibits this issue, something runnable without any async code in it?
It was very good idea to create sample app, during the process of this I have found up that I messed up while creating my implementation of a Wizard (I did not wanted a cancel button), Hovewer now when I got back to original Wizard everythink works fine including async preparation of wizard
Thanks for help!
Fantastic :) It wasn't my intention to be lazy, but it would be hard to debug based on the previous code sample and now we got some real value from it :) Feel free to post the code you created to test!
Will close because of inactivity