Open jbruchanov opened 3 months ago
I found a solution:
val fakeJFXPanel = JFXPanel()
fun main() = application {
...
}
I used a global variable to ensure that JFXPanel is initialized at the very beginning. This prevents the subsequent calls in the @Composable function from encountering the lateinit property component has not been initialized issue.
fun ComposeSwing(modifier: Modifier = Modifier) {
SwingPanel(factory = { JFXPanel() })
}
This is definitely not a standard solution; it's quite a hack and there is certainly room for optimization. However, it solved my current issue and I hope it helps you too.
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Describe the bug App crash due to
Affected platforms
Versions kotlin = "1.9.23" jetbrains-compose-ui = "1.6.1", "1.6.2", "1.6.10-dev1584 jvmtarget = "17" os: windows11
run following code on jvmDesktop
lateinit property container has not been initialized
having
visible
true by default (on start) works fine and the swing panel is rendered as expected, then uncheck -> check -> crash againProblem starts here
SwingPanel.desktop.kt#L165
when callingfactory()
Simple stackmight be related/similar to: https://github.com/JetBrains/compose-multiplatform/issues/519
compose_swing_stack.txt