File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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.
 
Consider Paul's rocket mass heater.
 
subject: align JLabel to left
 
Similar Threads
align JLabels and JTextFields vertically in different areas
BoxLayout alignment issue
basic swing layout problem.
push flowlayout panel to the left.
Problem With SpringLayout Component Placement