Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Text And Wordwrap In java.awt.Label  RSS feed

 
ch praveen
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,
As Iam doing my first java project, Iam facing many problems in buiding interface part of it which is based on AWT. I have created a Frame of size (400w,400h) and placed a Label in it. When I tried to set text for that Label, whole text is not visible, when the text is large. I want the text tobe displayed in the Frame whose size is (400w,400h) and it must undergo word wrap when text doesnot fit in the width of the frame thus accomplishing the task of rendering whole text in the Frame of size (400w,400h). Kindly guide me in this aspect.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure you need a Label to display the Text?
There are other Text-displaying Components which might be better.
JTextArea, JTextPane...
A solution might be to choose a smaller font, but this will only serve to a special level - a 1x1 pixel-font isn't very well readable.
Another solution would be to use Scrollpanes.
 
Eddie Vanda
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you change to javax.swing.JLabel your text can be a <html>this is some text on one line<br> and this is on another line </html>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!