Ask HN: Tips for modern Java Swing development?

1 points by rlawson ↗ HN
I'm writing some utilities with Java Swing (I'm a Java dev working in a Java shop). Been away from it a while - what is the best app framework? I have settled on flat laf (https://www.formdev.com/flatlaf) but what about MVC/app support? I found Griffon. Anything else?

6 comments

[ 3.4 ms ] story [ 10.8 ms ] thread
Is there still demand for Swing development? I would have assumed JavaFX is the way to go.
These are simple utilities and I know Swing but not JavaFX but I guess I should play around with it
I think the biggest flaw of Swing is that it didn’t provide or promote a standard ‘Controller’ class. I have seen tons of Swing code over the years that is a spaghetti code mess of UI creation, initialization, updating and responding.

So my big tip is to create a SwingController base class for any of your UI panes with the following methods:

  - JComponent createUI();
  - void initUI();
  - void resetUI();
  - void respondUI(Event anEvent);
Theres a bit more to it than that, since you want resetUI to update all of your components without triggering respondUI(). And you want all your components to be automatically configured to call respondUI() when there is user interaction.

I’ve written one of these before, but I don’t have access to a public version anymore. I do all my current UI dev in a UI kit built on top of Swing. But here is what I use there that solves this problem:

https://github.com/reportmill/SnapKit/blob/master/src/snap/v...

Thank you! I will read through this
Also I used ReportMill before at a prev job - very good software!
Wow - nice to hear and thanks for the compliment!

My contact info is in my HN profile - send me a note, maybe we should connect on LinkedIn.