• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextArea & TextArea

 
Patrick Mugabe
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!