Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Alignment

 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JLabel that gets added to a JPanel that eventually gets added into a bunch of nested JPanels and such. When it displays the JLabel's text appears to be centered and (because the text spans beyond the display area) both the front and the end of the text gets cut off from display (only middle of text is displayed). What is the best method to ensure the JLabel is not centered but rather display left to the right (front of string is shown but right is cut off only). Thanks in advance.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what layoutManager is used by the label's container panel?
(coule be an 'absolute positioning' issue)
 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty certain the JPanel holding the JLabel is using the default manager and the panel it's nested within is using FlowLayout. I don't have the code right in front of me at the moment, sorry.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> I'm pretty certain the JPanel holding the JLabel is using the default manager and the panel it's nested within is using FlowLayout.

to have the left side showing, right side cut off, change
 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FlowLayout has a left static constant? I didn't know that, thanks. I ended up using BorderLayout with WEST set and seems to do the trick. Thanks for the info. Appreciate it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic