🧠Theoretical question, but is it possible somehow hijack the rendering of Swing/JavaFx components to draw on composable layout? So not using swing components at all, just their render engine. For example, I want to hijack WebView rendering from Swing and draw all the contents in composable/skiko
a
Alexander Maryanovsky
09/03/2023, 8:57 PM
Sure, you can draw a JComponent into a BufferedImage and then convert that to a Skiko image and draw that in compose (I don’t remember the exact APIs, but I’m sure they exist). It wouldn’t be very performant, though.
🙌 1
r
romainguy
09/03/2023, 8:59 PM
I imagine that a WebView already does something like this and doesn't draw directly with Swing's Graphics APIs so it would be doubly expensive
z
Zach Klippenstein (he/him) [MOD]
09/03/2023, 11:06 PM
Could you use drawWithCanvas, get the native canvas out, then tell your WebView to draw into that? I think that would effectively be the same as just embedding the component though, as far as drawing is concerned.