aspose file tools
The moose likes Swing / AWT / SWT and the fly likes JTextArea & TextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "JTextArea & TextArea" Watch "JTextArea & TextArea" New topic
Author

JTextArea & TextArea

Patrick Mugabe
Ranch Hand

Joined: Jan 08, 2002
Posts: 132
When using the awt package, I have no problems developing a TextArea that has no scrollbars,
e.g
TextArea t = new TextArea("", 5, 30, TextArea.SCROLLBARS_NONE);
However I have faced problems trying to do the same thing using JTextArea.
Can anyone please show me how this can be done using JTextArea.
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
Ok, Swing components are a bit different than AWT components. A JTextArea and any other Swing component do not have the possibility to scroll.
That's why you have a JScrollPane. This means, if you want a Swing component to be scrollable, you have to wrap it with a JScrollPane.

If you use this code, and your text area doesn't contain any text, then you won't see any scrollbars. You will see it only if the text and with the text the JTextArea is larger, than you can see it. But this behavior is changable.
Just one hint, you should have a look to the Swing tutorial from Sun to have an overview about what is possible with Swing.
[ August 01, 2002: Message edited by: Rene Liebmann ]
 
I agree. Here's the link: http://jrebel.com/download
 
subject: JTextArea & TextArea
 
Similar Threads
Disable part of the Textarea
scrollbar as needed: but in a TextArea, not a JTextArea
How to read text file to JScrollPanel?
JTextArea()
JTextArea doesnot scroll automatically...