Sooo...
I just started designing the GUI for an application that I'm writing..
And, well, I can't get either the awt.TextArea OR the swing.JTextArea to work properly.
Here are snapshots of both, along with the problems I am experiencing.

If anyone can resolve these problems, please let me know..
I wanted to use JTextArea but it produces errors and functions terribly.
Both examples are enclosed in a JScrollPane, the JTextArea makes use of the Scrollbars, the TextArea does not (though it works well otherwise, besides displaying its OWN scrollbars).

Pay no attention to the sloppiness, the JLabels, etc, as I've just begun putting the GUI together. ;)

Swing.JTextArea -- Produces errors during runtime, JScrollBar works, but widgit functions terribly
[IMG]http://i12.photobucket.com/albums/a248/CudmoreMB/RandForums/dsktop_snapshot_JTextArea.jpg[/IMG]

Awt.TextArea -- Works welll, but isn't displaying its own ScrollBars properly, nor does it make ues of the JScrollPane
[IMG]http://i12.photobucket.com/albums/a248/CudmoreMB/RandForums/dsktop_snapshot_3.jpg[/IMG]

And yes, I've called the...

JSP.setVerticalScrollBarPolicy (JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
JSP.setHorizontalScrollBarPolicy (JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

And the...

new TextArea("", 5, 5, TextArea.SCROLLBARS_BOTH);

Create scrollbars that with swing constants that suit you, then setWrapStyleWord(true) to the text area. Then add the JTextArea TO THE JSCROLLBAR. (Then the scrollbar to the container)

JTextArea textarea = new JTextArea(params);

JScrollPane test = new JScrollPane(textarea,
                JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, 
                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

content.add(test);

Yep. That's pretty much what I had:

JTextArea output = new JTextArea("");
//output.setEditable (false); // leave true while testing

JScrollPane JSP = new JScrollPane (output);
JSP.setVerticalScrollBarPolicy (JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
JSP.setHorizontalScrollBarPolicy (JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		
JSP.setAlignmentX(0.0f);

add (JSP);

Did you add the scrollpane to the tabbedpane and then the tabbedpane to the container? Remember, there is no need to add the textarea to the container since it alread has a 'container' and the same with the scrollpanes if you want them on the tabbed pane

:cool: There was nothing wrong with my code.

It was the JRE/JDK..
I installed version 1.5 (I was using 1.4.2) and it works perfectly now.

Sorry for the confusion, but if anyone else encounters this problem, and if they read this, then they'll know what to do..

Note to all:
Suse 10.1 Linux; java-1.4.2; GUI problems

This article has been dead for over six months. Start a new discussion instead.