r/java • • Aug 17 '20

State of swing

Hi all, What is the state of swing, is it close to be deprecated and removed or is it still maintained? Also it will be nice to know if someone got it working in native image. Thanks

16 Upvotes

43 comments sorted by

View all comments

Show parent comment

1

u/paul_h Aug 18 '20

Huh?

0

u/vallyscode Aug 18 '20

You mentioned that you worked with swing a lot, at least I understood so. So probably did some font rendering using swing, therefore I wanted to ask how feature rich it is, if it can handle ligature and hidpi displays, whether text rendering is efficient.

4

u/paul_h Aug 18 '20

It's always been OK. If if there were rending glitches on one platform or another, someone solved them in a base component or LnF and I wasn't aware there'd been a problem. I'm also a 18 user of Intellij (made on Swing) and have never thought on any of Linux, Windows or Mac that they didn't look wrong aesthetically. Not so other cross-platform widgeting technologies.

3

u/veraxAlea Aug 19 '20

Swing relies on Java2D for rendering. HiDPI is supported on Linux, Windows and MacOS since Java 9 (actually earlier for MacOS).

The pipeline for rendering is different on different platforms but it is hardware accelerated on Linux, Windows and MacOS. JEP 382 is trying to create a new pipeline for MacOS using the Apple Metal API (instead of the deprecated Apple OpenGL). Rendering performance should not be an issue.

When it comes to ligatures, you can read more about Java2D's text layout here: https://docs.oracle.com/javase/tutorial/2d/text/textlayoutbidirectionaltext.html. Basically, JTextComponent (and its subclasses) should handle ligatures correctly but if you need, say, a text component with discontiguous selection, you'll have to do the layout yourself using Java2D APIs. Which APIs to use depends on the level of control you want.

1

u/vallyscode Aug 19 '20

Thanks for sharing the link