jvmMain.io.mths.swing.flow.ObserveInPanel.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swing-flow Show documentation
Show all versions of swing-flow Show documentation
Kotlin Flow integration for Swing.
The newest version!
package io.mths.swing.flow
import io.mths.swing.flow.binding.invoke
import io.mths.swing.flow.binding.shorthand.binds
import kotlinx.coroutines.flow.*
import javax.swing.JComponent
import javax.swing.JPanel
fun Flow.observeInPanel(): JComponent =
JPanel() binds {
::setContent { this@observeInPanel }
}
private fun JComponent.setContent(newContent: JComponent) {
removeAll()
add(newContent)
}