DEV Community

Discussion on: From Swing to Jetpack Compose Desktop #2

Collapse
 
thijsiez profile image
Thijs Koppen • Edited

Hej Thomas, thanks a lot for this write-up, really helped me out a lot! I just updated to v0.4.0 and I feel that the new Window and Dialog composables (with state parameter) break the above code. It worked fine in v0.4.0-build209 which I was using before.

I browsed a bit through the new code and found that those composables provide a WindowScope or DialogScope to the content composable. These contain a window or dialog field, which in turn give us a contentPane. So with a small change to the above code, we can attach to a Window or Dialog's dropTarget like this:

Window(state) {
    window.contentPane.dropTarget = object : DropTarget() {
        ...
    }
}
Enter fullscreen mode Exit fullscreen mode

Hope that helps someone :)

Collapse
 
tkuenneth profile image
Thomas Künneth

Awesome. Thanks for bringing this up. Maybe I should do some sort of follow-up to the series. Thanks. 👍