New Compose Multiplatform components arrived on Composables UICheck it out →

Component in Compose Ui

SwingPanel

Desktop

Composes an AWT/Swing component obtained from [factory]. The [factory] block will be called to obtain the [Component] to be composed.

The Swing component is placed on top of the Compose layer (that means that Compose content can't overlap or clip it). This can be changed in the future, when the better interop with Swing will be implemented. See related issues: https://github.com/JetBrains/compose-jb/issues/1521 https://github.com/JetBrains/compose-jb/issues/1202 https://github.com/JetBrains/compose-jb/issues/1449

The [update] block runs due to recomposition, this is the place to set [Component] properties depending on state. When state changes, the block will be reexecuted to set the new properties.

Last updated:

Installation

dependencies {
   implementation("androidx.compose.ui:ui:1.7.0-beta04")
}

Overloads

@Composable
fun <T : Component> SwingPanel(
    background: Color = Color.White,
    factory: () -> T,
    modifier: Modifier = Modifier,
    update: (T) -> Unit = NoOpUpdate
)

Parameters

namedescription
backgroundBackground color of SwingPanel
factoryThe block creating the [Component] to be composed.
modifierThe modifier to be applied to the layout.
updateThe callback to be invoked after the layout is inflated.