I am trying to do something in Java which requires me to have a JTextArea in a ScrollPane.
Here is how I have defined them:
private JTextArea longestparagraph = new JTextArea();
....
JScrollPane scrollpanedreapta = new JScrollPane(longestparagraph,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollpanedreapta.setBorder(BorderFactory.createTitledBorder("Cel mai lung paragraf:"));
The problem I'm encountering is that the text doesn't start on a new line when it reaches the right border of the TextArea but it continues. Got any ideas how to solve that? Here's a picture to make my statement a little bit clearer.
Found the answer. Just had to this:
longestparagraph.setLineWrap(true);
longestparagraph.setWrapStyleWord(true);