• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

How do I wrap a Label in AWT?

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have a problem. I have a lot of text that needs to be displayed, but I can't get the Label object to word wrap. I know if I used JLabel that I could use HTML, but Swing is not an option for this project. If someone could help it would be greatly appreciated.
Thanks,
Trish
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi in AWT i dont think u can directly get a Wrapping label.u can get more info from the below link..
http://www.codeproject.com/useritems/vwrappinglabel.asp
it includes an example, showing
creation of a Wrapping Label

Raj
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Patricia,
I have a cleaner approach that subclasses a Label and makes use of StringTokenizer to split the string into lines.

Enjoy,
Manfred
 
Patricia Fulk
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you both. I now have a label that wraps!
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to Manfred. I have added a constructor that specifies a maximum line length, which I found useful.
Here it is as a small pay-back for all the good stuff here:

[ March 17, 2003: Message edited by: Dave Mulligan ]
 
I didn't do it. You can't prove it. Nobody saw me. The sheep are lying! This tiny ad is my witness!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!