分享

JLabel Word Wrap

 szarhen 2012-03-23
Dmitry Zhelezov 
Greenhorn 

Joined: Dec 29, 2008
Posts: 3 
try the following: 

[code] 
JLabel label = new JLabel("<html><table><td width='\" + width + ""\>Some very very very very very long text </td></table></html>") 
[/code] 
where width is width you want label to fit on. i used parent panel width - borders width.

This message was edited 1 time. Last update was at Friday, February 12, 2010 22:48:29 by Dmitry Zhelezov

Tony Fecteau 
Greenhorn 

Joined: Aug 27, 2010
Posts: 1 
Use html tags and set preferred size to 1x1. It will automatically resize 
  1.  JLabel label = new JLabel("<html>your text here</html>");  
  2. label.setPreferredSize(new Dimension(11);   

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约