• Post Reply Bookmark Topic Watch Topic
  • New Topic

HTML brings in problems on Layout.

 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to add a JLabel to the extreme right of the JMenuBar. It need to have a gap between menus and JLabel, so I add a glue first, then add the JLabel


The "Hello World" appears on the extreme right. But when I try to add some HTML tags to the JLabel, then bad thing happened. The "Hello World" appears just next the menus.It seems the HTML tag brings in troubles to Layout.

How to do this layout if I still want to use HTML tags? Thanks.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you try this, instead of the 'glue'
menuBar.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael, this applys for all the menus, not just the label I added. But I've tried to do this to the label. Then the "Hello World" appears to the extreme right.

But that's not enough.The problem is when normal text, the label's size is the length of the text. When use HTML tag, the label expand all the space left.The glue lost. I use a bevel border to know this. Anyone has suggestions on this? Thanks.

[ This problem finaly resolved by lable.setMaxSize(label.getPreferedSize())
I'm just curious why Swing behaves like this when HTML tags added.
]

[ August 02, 2006: Message edited by: Loius Wan ]
[ August 02, 2006: Message edited by: Loius Wan ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!