Are there any examples of including a Swing compon...
# compose-desktop
j
Are there any examples of including a Swing component? I'm looking to see if I can use https://github.com/msteiger/jxmapviewer2 to show a map. All I've seen so far is that I can do following but adding to that using something like
jFrame.contentPane.add(mapViewer)
isn't working
Copy code
val current = AppManager.getCurrentFocusedWindow()
val jFrame = current.window
j
cc @olonho
o
We have an internal prototype for cooperation of Swing and Compose inside the same JFrame, but it’s not yet productized.
f
I'm experimenting with this. I was able to add JComponent to the window of AppWindow. Take a look here: https://gist.github.com/Foso/88cde0855153d8851d1368fc64404033
l
Ok, so, I can’t to use JInternalframe inside a JFrame?, for example:
Copy code
val jFrame = AppManager.focusedWindow?.window

val internalFrame = JInternalFrame("Internal Frame 1", true, true, true, true)
internalFrame.setSize(400, 400)

jFrame?.add(internalFrame)
Basically I can’t to use this https://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html for the moment?
j
@olonho just in case there was anything further available that would allow this? Basically trying to show a map as part of Compose app
o
Not in Compose render tree, but you could put it nearby, see https://github.com/JetBrains/compose-jb/tree/master/tutorials/Swing_Integration
j
Thanks, will try that
Is there particular build that you'd recommend using....the code I had was still using
0.1.0-build63
but looks like that code depends on changes made after that?
o
Yes, 0.2.0-build127 or 0.2.0-build128 shall do. Second is for Kotlin 1.4.20.
j
ah, that might cause an issue for current Compose (Android one)....think alpha07 version doesn't work with 1.4.20 yet
(though there is snapshot version of that that does work with 1.4.20 that I could probably start using)
o
We build both desktop and Android
👍 1
j
Thanks @olonho, got something basic up and running using that sample as starting point
🎉 3
(Compose UI on left and
JXMapViewer
panel on right)