• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

JTextArea & TextArea

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic