This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes align JLabel to left Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "align JLabel to left" Watch "align JLabel to left" New topic
Author

align JLabel to left

kalyan chowdary
Greenhorn

Joined: Jun 22, 2006
Posts: 24
Hi,

I create a labels in JPanel,

JPanel is set to GridBagLayout,

but i want to put JLabel to left align,

i use
JLabel label=new JLabel("Item Name",JLabel.LEFT);

but its not working.

Help me,

Thanks in advance;
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

All that the JLabel.LEFT in the constructor does is to tell the label to left-align it's contents. Depending on how the label is laid out in it's container this may or may not make a difference. (i.e. - if the label itself is only the size of the text, then it won't look any different. If the label itself is larger than the text, then the text will shift to the left.)

Check the size your label is in the layout of it's container - an easy way to see this is to set a border on your label.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: align JLabel to left