aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Alignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Alignment" Watch "Alignment" New topic
Author

Alignment

Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
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

Joined: Jun 09, 2003
Posts: 4632
what layoutManager is used by the label's container panel?
(coule be an 'absolute positioning' issue)
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
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

Joined: Jun 09, 2003
Posts: 4632
> 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

Joined: Apr 09, 2002
Posts: 805
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Alignment
 
Similar Threads
removing space for text in JLabel . . .
JMenuItem centering
JLabel centered in a JPanel
BoxLayout not working as advertised?
Inclined Text of JLabel