How to setLocation()?

i don't know wheather i could post the topic here or to "new to java",because i am a beginer ,my problem may be to easy for others.

ok,my problem is how to set a Jlabel to another positon. look at my code here:

import javax.swing.*;

import java.awt.*;

publicclass ImageShowextends JFrame{

private JLabel label;

private JPanel panel;

ImageIcon icon ;

ImageShow(){

//this.setLayout(null);

label=new JLabel();

this.setSize(500,500);

icon=new ImageIcon(getClass().getResource("robot.gif"));

label.setIcon(icon);

this.getContentPane().add(label);

setVisible(true);

//question one ?

System.out.println(label.getWidth());

System.out.println(label.getHeight());

System.out.println(this.getWidth());

System.out.println(this.getHeight());

}

publicvoid move(int x,int y){

label.setLocation(x,y);

}

publicstaticvoid main(String args[]){

ImageShow image=new ImageShow();

//question two ?

image.move(500,500);

}

}

the problem is :

one : someone said i should setBounds() before setLocation,so i want to know the width and the heigth of the imageicon,but when i print the label 's width and height,why its number so big,the width is 492,the height is 466,the frame width and height is only (500,500),and the picture "robot"is a small picture, i don't know why.

two: i invoke move() just to move the label to another position,but actually it doesn't work,i even can't see the imageicon,why? then how to setLocation() here or how to move the imageicon to another position?

[2590 byte] By [suncs2001a] at [2007-11-27 4:39:31]
# 1

setBounds() includes location.

with the commented out null layout, the frame's default layout is BorderLayout,

and the default position is center. so, when you add the label

this.getContentPane().add(label);

because it has been added to center, it will occupy all of the available space

i.e. the frame's width minus margins, frame's height minus margins minus titleBar

the layoutManager is responsible for the positioning of the component,

so move() will do nothing

Michael_Dunna at 2007-7-12 9:50:12 > top of Java-index,Desktop,Core GUI APIs...
# 2
so what should i do? i can't move the imageicon forever?
suncs2001a at 2007-7-12 9:50:12 > top of Java-index,Desktop,Core GUI APIs...
# 3
If you are trying to animate the moving of an image then check out my reply (or the other replies) in this posting: http://forum.java.sun.com/thread.jspa?forumID=57&threadID=631379
camickra at 2007-7-12 9:50:12 > top of Java-index,Desktop,Core GUI APIs...