Hello all, I have a very large JavaFX app that I w...
# compose-desktop
j
Hello all, I have a very large JavaFX app that I would like to migrate to Compose over time. I have a few questions that I've had trouble finding answers to. 1. Is it possible to host compose within a JavaFX node, or JavaFX within compose? 2. If so, how difficult would it be to create the same look and feel? 3. UI lives in both the base app and hot-loaded JARs. Would everything require the exact same compose compiler version?
k
What’s your current Javafx look and feel
m
1. Should be doable by running JavaFX inside compose via kotlinlang.org/docs/multiplatform/compose-desktop-swing… but I have never done it myself. In practice I wouldn't recommend it. When you are coming from JavaFX, the first thing you have to learn is that everything you learned so far is different for Compose. It needs a completely different kind of thinking which is difficult enough already initially. Then even trying to top that by mixing both worlds in one program is a ticket for frustration.
k
Different thinking would be a given in any mix of two different UI toolkits. The options here would be: 1. Stay in JavaFX completely 2. Rewrite the whole thing in Compose 3. Start migrating smaller pieces one at a time Number 3 is what JB is doing right now with IntelliJ and other IDEs. It takes time, of course. Jewel is there as the answer to question #2, specifically for the look-and-feel of this specific product line.
j
The JavaFX theme is mostly just tweaks to the default. I'll take a look at Jewel to see what it would take to replicate.
k
Modena? Caspian? I don't think anybody ported either one of those to Compose desktop.
j
Modena
k
Certainly you have a few options for theming. The biggest adjustment might be that Compose does not have the same separation between controls and styling as JavaFX or Swing do. In Compose, controls and styling are together in the design library. github.com/composablehorizons/compose-unstyled aims to bring this distinction into Compose, to a certain degree. That can be your starting point. Jewel is very much integrated with how IntelliJ handled theming in the Swing world, and I think it continues down the road of reading all the relevant styling information from the same place (invoking @seb to keep me honest). Aurora (my project) is another design system (components + styling) that you can look at for how things can be implemented.
j
Thanks, will do!
s
Yep can confirm. Jewel in the IDE reads as much as possible from the LaF. In standalone apps we don't bother, we ship defaults
a
Technically it is possible both ways. There could be same problems with flickering as with swing integration (different schedulers for frame rendering on resize). But theming is hard. Jewel is probably the only way. Last time I checked it required JetBrains runtime though.
s
It requires JBR mostly because it's the only JVM that supports a bunch of things properly. Except for decorated windows, it's a soft dependency, but a very strongly recommended one (and we don't take bugs if you're not running JBR)
a
I tried it some time ago and it did not work without JBR. I think I will give it another try. I do not like Material design visuals on desktop.
s
We used to have only loud log complaints (except if you use decoratedwindow since that depends on jbr-api), I forget if there are other hard dependencies but I don't think so given some people manage to make it run on graalvm native image
m
@altavir I am just curious. What exactly is it what you do not like in Material. After some tweaking I didn't find the result so bad.
a
It looks fine in mobile application, maybe web. But for industrial desktop application violet rounded buttons is not something our users expect. I just does not play well with other desktop applications.
m
That's what I meant by tweaking and it wasn't very difficult.
a
Could you share what app this is? Is it publicly available?
m
The application itself is not public but I have posted a screenshot here: github.com/maplibre/maplibre-compose/discussions/966#… I think it doesn't look so bad for a desktop-app and it uses Material3 wrapped in a Nucleus Tao window (not the default AWT).