Open igordmn opened 3 years ago
It seems this code works:
import androidx.compose.desktop.SwingPanel
import androidx.compose.desktop.Window
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import java.awt.Color
import javax.swing.JPanel
fun main() = Window {
Box(
modifier = Modifier.fillMaxSize().background(color = androidx.compose.ui.graphics.Color.Green )
) {
SwingPanel(
factory = {
JPanel().apply {
background = Color.RED
}
}
)
}
}
But doesn't work when we add Modifier.fillMaxSize()
to the SwingPanel
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Compose 0.4.0, 0.4.0-build174 (everything is ok in 0.4.0-build173)
Expected: panel is resized Actual: size of the panel doesn't change
The problem lies in
Modifier.onGloballyPositioned
that is used by SwingPanel. This code also works in 0.4.0-build173: