Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / June 2005

Tip: Looking for answers? Try searching our database.

Word wrap on a JTextArea?

Thread view: 
Allan Bruce - 02 Jun 2005 21:53 GMT
How do I make the text in my JTextArea wrap so that I dont need a horizontal
scrollbar?  I tried setting it to not scroll horizantally ever but the text
just keeps drawing and I cant see it.
How can I get it wrapping?

Thanks.
Allan
Roland - 02 Jun 2005 22:03 GMT
> How do I make the text in my JTextArea wrap so that I dont need a horizontal
> scrollbar?  I tried setting it to not scroll horizantally ever but the text
[quoted text clipped - 3 lines]
> Thanks.
> Allan

myJTextArea.setLineWrap(true);
myJTextArea.setWrapStyleWord(true);
Signature

Regards,

Roland de Ruiter
  ___      ___
 /__/ w_/ /__/
/  \ /_/ /  \

Allan Bruce - 02 Jun 2005 23:03 GMT
>> How do I make the text in my JTextArea wrap so that I dont need a
>> horizontal scrollbar?  I tried setting it to not scroll horizantally ever
[quoted text clipped - 5 lines]
> myJTextArea.setLineWrap(true);
> myJTextArea.setWrapStyleWord(true);

Perfect, thanks!
Allan
Robert Maas, see http://tinyurl.com/uh3t - 11 Jun 2005 06:03 GMT
> From: "Allan Bruce" <amb@abc.net>
> How do I make the text in my JTextArea wrap so that I dont need a
> horizontal scrollbar?

Given that you already knew the name of the class you are working with,
and obviously you have some sort of online access to the net, why
didn't you look in the API documentation, in the list of classes for
J2SE, for example I use 1.3.1 so I'd look here:
 http://java.sun.com/j2se/1.3/docs/api/allclasses-frame.html
and then do a simple search for the name of your class on that Web
page, which would turn up the link to this:
 http://java.sun.com/j2se/1.3/docs/api/javax/swing/JTextArea.html
and then searching down the list of methods you'd see the link to this:
 http://java.sun.com/j2se/1.3/docs/api/javax/swing/JTextArea.html#setLineWrap(boolean)
not to mention that up at the start of the page for that whole class
there's an explanatory section that says this:
  ... JTextArea has a bound property for line wrapping that
  controls whether or not it will wrap lines. By default, the line
  wrapping property is set to false (not wrapped).
Did you fail to see either that descriptive text or the late specific
method for setting line-wrap property? Or did you not even bother to
look at the API before posting? The Java API has a few typos here and
there, but generally is mostly correct and very easy to use online. Try
it, you'll like it!

And for times when you can't be online and just need a list of method
and constructor signatures without the full English-language
descriptive text, BeanShell has a fine class browser, I discovered a
few days ago, and it includes not just the Java API, but any other
classes you have in your classpath, including other packages (such as
BeanShell itself) you've downloaded as well as all your own classes
whether in packages or not.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.