aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Why can't i control location of label? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Why can Watch "Why can New topic
Author

Why can't i control location of label?

Ana Suvari
Ranch Hand

Joined: Aug 18, 2009
Posts: 43
I have background picture and a label that is suppose to go on top of it but i can't seem to control it's location.

Setting the location seems to have no effect. I tried increasing the numbers but the textLabel won't budge. It's not exactly at (0,0) of the panel.
It is actual 1/4 to the right and less than 1 row down.

pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
You need to read the Sun tutorials on the layout managers to understand what is happening and why. For one, the container you are placing your label in is using a layout manager, possibly FlowLayout as a default layout, and so setLocation won't work. setLocation works when using a null layout, but having said that I don't recommend that you use this, but instead learn to use and nest the various layout managers.

I will request that the mods move this question to the Swing forum.

Best of luck!
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

Agree with Pete.
Moving.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
all you seem to be doing is copying working code (latest from this forums FAQ),
adding stuff, then posting it here with a 'this doesn't work'.

the changes you make indicate very little understanding of the basics of swing,
so I'd suggest you start the tutorials earlier than the layout managers.
Ramses Butarbutar
Ranch Hand

Joined: Jun 16, 2009
Posts: 52
Hi Ana,
I have a great LINK to learn java swing... It show you how to use layout manager and etc..
Just sit back, make some coffee (java coffee ) and check out the link..Have a nice study..


At the center of non-violence stands the principle of love
.... Martin Luther King, Jr.
Alan Mehio
Ranch Hand

Joined: Apr 04, 2005
Posts: 73
Ana Suvari wrote:I have background picture and a label that is suppose to go on top of it but i can't seem to control it's location.

Setting the location seems to have no effect. I tried increasing the numbers but the textLabel won't budge. It's not exactly at (0,0) of the panel.
It is actual 1/4 to the right and less than 1 row down.




This is a good candidate for a custom painting. Extends the JLabel and overide the painComponent method

example can be supplied if wanted


Regards,
Alan Mehio
London, UK
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why can't i control location of label?
 
Similar Threads
how to Implement array of Components?
JLabel not showing
problem using button event handler to update text in a frame
Overlapping MouseListeners
Mouse shift event coding - to trigger a predetermined sequence of images to a GUI