bod
01/21/2023, 11:37 AMComposePanel
(with isVisible = false
) doesn't seem to work - the UI stays visible (but is no longer interactive). This looks like a bug but just wanted to check here first.
Anyone has seen this before?
Reproducer in 🧵fun main() = SwingUtilities.invokeLater {
val composePanel = ComposePanel().apply {
setContent {
Button(
onClick = {
isVisible = false // <- this should hide the ComposePanel but doesn't
}
) {
Text("Hello World")
}
}
}
JFrame().apply {
setSize(800, 600)
contentPane.add(composePanel)
isVisible = true
}
}
Alexander Maryanovsky
01/21/2023, 12:27 PMComposePanel
is visible before rendering it. Judging by the animation, though, maybe we aren’t rendering it when invisible, but also not clearing the last rendered frame.
Any way, you can use something like this as a workaround:
fun main() = SwingUtilities.invokeLater {
val composePanel = ComposePanel().apply {
setContent {
var visible by remember{ mutableStateOf(true) }
if (visible){
Button(
onClick = {
visible = false
}
) {
Text("Hello World")
}
}
}
}
JFrame().apply {
setSize(800, 600)
contentPane.add(composePanel)
isVisible = true
}
}
bod
01/21/2023, 12:39 PMAlexander Maryanovsky
01/21/2023, 12:40 PMbod
01/21/2023, 12:41 PMAlexander Maryanovsky
01/22/2023, 7:05 AMbod
01/22/2023, 2:54 PMAlexander Maryanovsky
01/22/2023, 4:47 PMaddHierarchyListener
? https://docs.oracle.com/javase/7/docs/api/java/awt/event/HierarchyEvent.htmlbod
01/22/2023, 9:48 PM