Is there a library that would give me 2D graphics with a focus on Text for Swing. I am building a simple form designer and need to position text correctly on a 2D display. It would be nice if there was a library that handled the newlines and possibly editing.
An approach I've used successfully in the past is to draw your form with Graphics2D into a single panel. Graphics2D gives you precise text and line positioning. When you want to edit the text, have the user click on the text and place a JTextArea or similar into the panel where the text is while the user edits.
I like the answer that suggests using a JTextArea when the user is going to edit text, since it is simple. However, if you want true in-place editing, while also rendering exactly your text content, you could investigate creating your own View implementation for a JEditorPane. This gives you a ready-made model and controller for editing, allowing you provide the presentation, so you can render as accurately as necessary. And with the JEditorPane.DefaultEditorKit available as source, you have plenty of guidance about how to implement your own View.
This may be overkill for your needs, or it may give you the fine level of control needed.