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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Need help with using layout." Watch "Need help with using layout." New topic
Author

Need help with using layout.

Willie Tsang
Greenhorn

Joined: Nov 20, 2011
Posts: 24
My problem is, I want my Jlabel to appear at the 0,0 location, as coded in the grdibagconstraints, but it appears in the center if i run this code. I already read alot of the apis, but it didn't help. Please help. Thanks


Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
add the additional 2 lines

c.weightx = 0.5;
c.weighty = 0.5;//<---
c.anchor = GridBagConstraints.NORTHWEST;//<---
Willie Tsang
Greenhorn

Joined: Nov 20, 2011
Posts: 24
Thanks for reply, but when i change the values of
c.gridx = 0;
c.gridy = 0;
it stays at NORTHWEST.
is there a way to change its location according to the x,y?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Could be wrong (usually am), but I have a sneaking suspicion you can't just 'place'
components here-and-there in GBL e.g. at 1,1 with no other components.

you may need to add a JPanel at 0,0 then use an appropriate layoutManager
for the panel to add your label where you want it.
Willie Tsang
Greenhorn

Joined: Nov 20, 2011
Posts: 24
Thanks alot for your post. Ill confirm that by reading the api, and mean while ill try different layouts. Thanks.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Willie Tsang wrote:Ill confirm that by reading the api, and mean while ill try different layouts.

That word is "I'll" and is short for "I will" or "I shall"

luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help with using layout.