seguinte…
Finalmente consegui fazer da forma que eu queria
Agradeço a todos pela paciencia
Vlew mesmo Mario.fts Marcos Lima alexfmjr e o ViniGodoy
segue o fonte fungando
package celulas;
public class Main {
public static void main(String[] args) {
Tela tela=new Tela();
}
}
package celulas;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Tela {
JLabel label;
public Tela(){
JFrame frame=new JFrame();
frame.setVisible(true);
frame.setLayout(null);
frame.setSize(900, 700);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
System.out.println("00000000000000000000000000");
for(;;){
Pane pane= new Pane();
Thread th=new Thread();
th.start();
frame.add(new Pane());
System.out.println("wwwwwwwwwwwwwwwwww");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
}
}
}
package celulas;
import java.awt.EventQueue;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
public class Pane extends JLabel{
int x=10;
int y=10;
public Pane(){
ImageIcon icon = new ImageIcon("C:/Users/billy/Documents/NetBeansProjects/celulas/src/celulas/y.gif");
setVisible(true);
x = 1+(int)(Math.random() * 769);
y = 1+(int)(Math.random() * 575);
setBounds(x, y, 31, 25);
setIcon(icon);
Thread labelThread = new Thread(new LabelRunnable(), "cel thread");
labelThread.setDaemon(true);
labelThread.start();
}
private class LabelRunnable implements Runnable {
public void run() {
for(;;) {
EventQueue.invokeLater(new Runnable() {
public void run() {
System.out.println("sdfsdfsdf");
int i = 1+(int)(Math.random() * 8);
System.out.println(""+i+"");
switch (i) {
case 1: if(y<=0){
y=y+100;
}
y--;
break;
case 2: if(y<=0){
y=y+100;
}
if(x>=769){
x=x-100;
}
x++;
y--;
break;
case 3: if(x>=769){
x=x-100;
}
x++;
break;
case 4: if(y>=575){
y=y-100;
}
if(x>=769){
x=x-100;
}
x++;
y++;
break;
case 5: if(y>=575){
y=y-100;
}
y++;
break;
case 6: if(y>=575){
y=y-100;
}
if(x<=0){
x=x+100;
}
x--;
y++;
break;
case 7: if(x<=0){
x=x+100;
}
x--;
break;
case 8: if(y<=0){
y=y+100;
}
if(x<=0){
x=x+100;
}
x--;
y--;
break;
}
setBounds(x, y, 31, 25);
}
});
try {
Thread.sleep(50);
} catch (InterruptedException e) {
}
}
}
}
}
:lol: