You're executing an infinite loop inside a single thread. When new what();
is created, the loop starts and never ends. As such c.setVisible(true);
is never reached.
You will need to create a separate thread for this loop to be run in. You could create the following class;
public class Infout implements Runnable{
private JFrame frame;
private JLabel image;
private Random s = new Random();
public Infout(JFrame frame, JLabel image){
this.frame = frame;
this.image = image;
}
@Override
public void run() {
while(true){
int x = s.nextInt(1000);
int y = s.nextInt(900);
try{ Thread.sleep(1000); }
catch(InterruptedException e){ }
image.setBounds(x, y, 200, 200);
}
}
}
and then instantiate and run in your main method like so;
Infout inf = new Infout(c, image);
new Thread(inf).start();
I hope this helps :)