Hacker News new | ask | show | jobs
by vips7L 2395 days ago
Swing is probably the wrong choice if youre going java. I do electron everyday for work and we use stdin/stdout to farm json to a Java process as well. Given the chance I would probably use JavaFX over Electron or Swing. The FX app will be easier to style than swing and Gluon just announced native compilation support via Graal for new FX apps [0].

[0] https://gluonhq.com/gluon-substrate-and-graalvm-native-image...

2 comments

I agree with you. JavaFX is better than Swing for most use cases.

I gave the Swing "Hello World" example because it shows a minimal, simple example of how little code is needed to create cross-platform GUI in Java.

JavaFX is also technically an external library now since Oracle spun out JavaFX to OpenJFX and Gluon has taken over development and maintenance, although many but not all OpenJDK distributions include it.

Makes sense. The tornadofx hello world is pretty minimal too:

    class HelloWorld : View() {
      override val root = HBox(Label("Hello world!"))
    }

    class HelloWorldApp : App() {
      override val primaryView = HelloWorld::class
    }
I've bee conflicted in my research on choosing Tornado or default JavaFX
I'm waiting for Tornado to support Java 11+ before I jump on the bandwagon. It's getting closer[1], but it's still not production ready, from what I can tell.

[1]: https://github.com/edvin/tornadofx/issues/899

Well I guess that makes it easier. I'd rather write Java than Kotlin anyway.
Really? That's the first time I've ever heard someone say that. What is it about Kotlin you don't like?
I just like Java. I know it well and mainly don't have issues with the problems kotlin is trying to solve. The main benefits I see of kotlin are coroutines (coming to java with project loom) and nullable reference types (which isn't a deal breaker for me).

I also don't enjoy functional programming, I find that it quickly becomes unreadable and kotlin is a weird mix between FP and OOP.

Last I checked (late last year) JavaFX hadn't HiDPI support.
According to the release notes for version 8 HiDPI is supported.
Is that for Gluon? Sorry for not looking it up myself, but it's probably worth pointing out that at least Swing has (kindof) Oracle and a major Java desktop app behind, whereas JFX hasn't seen any love at all. I played around with JFX a couple years ago but there were serious problems with its WebKit integration. Coming to think about it, I'm wondering if there are any plans to integrate JFX and WebKit on GraalVM as a serious Electron contender.