Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I wrap a Label in AWT?  RSS feed

 
Patricia Fulk
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
 
Rajendar Goud
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
 
Manfred Leonhardt
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!
 
Dave Mulligan
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 ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!