Here is a textarea I have put in my program using netbeans. The first image shows what the textarea looks like when I run the program. The second image is show the textarea afte
Try this http://java-sl.com/tip_text_height_measuring.html
I haven't tried it with JTextArea but suppose it should work
Include the JTextArea inside a JScrollPane
JTextArea textArea = new JTextArea();
JScrollPane scrollArea = new JScrollPane(textArea);
This will dynamically change the text area based on if scrolling is needed or not
I wouldn't use JTextArea for anything except prototyping. It has the bitter functionality of notepad. But it's up to you.
I would use a JEditorPane or JTextPane. I know you can't size it based on character size but that's for the best. For word wrap, you can do setContentType("text/html"); and wrap the text in <'p><'/p> tags.
(Note you still use JScrollPane for scrolling. In fact, the scroll pane works for any component)
See the differences: http://docs.oracle.com/javase/tutorial/uiswing/components/editorpane.html