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?

