Context
At the moment, I have a JTextArea that was created like this:
JTextArea descArea = new JTextArea(); descArea.setFont(style.getFont()); descArea.setLineWrap(true); descArea.setName("descArea"); descArea.setToolTipText(resourceMap.getString("descArea.toolTipText")); descArea.setText(model.getName()); JScrollPane descPane = new JScrollPane(descArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
When the user enters something into the field, he really wraps up (according to descArea.setLineWrap(true) ), but does it a little awkwardly, breaking words, as in the following example:

Our software users expect the packaging to become a little smarter and automatically generate something more:

With the general idea that when they print the last "th", it all moves to the second line along with the insertion point as they are entered (similar to almost any other text editor).
Question
My initial thought was to manually implement this sorting manually using a Key Listener, but I was wondering if there is a better approach / other component that could easily achieve this function?
source share