News for hackers. Stuff that matters.
Re:Ask HN: Tips for modern Java Swing development? by jeffreportmill1 on Saturday January 14, 2023 @11:40AM (#34381586)
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...

Re:Ask HN: Tips for modern Java Swing development? by rlawson on Saturday January 14, 2023 @12:39PM (#34382084)
Thank you! I will read through this
Re:Ask HN: Tips for modern Java Swing development? by rlawson on Saturday January 14, 2023 @09:20PM (#34386160)
Also I used ReportMill before at a prev job - very good software!
Re:Ask HN: Tips for modern Java Swing development? by jeffreportmill1 on Sunday January 15, 2023 @11:14AM (#34390456)
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.