• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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 ]
 
When all four tires fall off your canoe, how many tiny ads does it take to build a doghouse?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic