I have a JLabel text displayed in an Introductory text in a dialog. How can I make it fit in with the dialog width and automatically wrap to next line nicely? Right now, when the text is long, it changes my dialog size (width) to fit the text in. That make the dialog looks bad. Is ther any better way to do this ? Maybe I should use JTextArea not JLabel? Please help. Thanks!
You can use HTML for Label text. Here is the code sample label.setText(<HTML> Line1<br> Line2</HTML>");
Joined: Aug 07, 2003
Hi YIJAY, Thanks for your reply. The HTML solution does not really help because I don't know where to break. My label could be very long and it is translatable. In different language, the length varies. I have figured out that if I use JTextArea and textArea.setLineWrap(true); textArea.setWrapStyleWord(true); works for me. Maybe there are better way to do so. Thanks a lot!