• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why can't i control location of label?

 
Ana Suvari
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agree with Pete.
Moving.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..

 
Alan Mehio
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic