compose-multiplatform
compose-multiplatform copied to clipboard
SwingPanel requires a fixed content size
Describe the bug
If you don't set a fixed size on SwingPanel
and its contents, the component will have an arbitrary size or cause crashes in the Compose Node layout pass.
Affected platforms Select one of the platforms below:
- Desktop
Versions
- Kotlin version*: 1.7.20
- Compose Multiplatform version*: 1.2.1
- OS version(s)* (required for Desktop and iOS issues): macOS/Swing
- OS architecture (x86 or arm64): arm64 but irrelevant
- JDK (for desktop issues): 17
To Reproduce Steps and/or the code snippet to reproduce the behavior:
- Create an IJ plugin project (using the template in the samples in this repo)
- Create a LazyColumn and add items to it
- Make those items be a SwingPanel that contains a non-size-constrained JComponent
- Observe the items get sized incorrectly
Expected behavior Components shouldn't have to be fixed size, as it's a big limitation. You don't always know what size you need in advance.
I have a repro here: https://github.com/rock3r/cfd-repros/blob/main/src/main/kotlin/ComposePanelFixedSize.kt
The ComposePanel
's content doesn't show up unless I set a fixed height on it. If I use heightIn(minH, maxH)
the panel will always be sized to minH
, which is also wrong. I suspect this to be related to #4556, but it's slightly different.
The original crash I was seeing happened because I used an IntelliJ's EditorTextField
inside it, which is scrollable, and I was in a LazyColumn
. In the simple repro, there is no crash, but it still does not work as intended.
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.