shipwreck 0 Newbie Poster

I'm trying to get a 'fish' to move randomly within an aquarium. I've got the fish drawn, but can anybody help me on getting him to move randomly? Any help would be greatly appreciated.

-- Shipwreck

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class Fish
{
  public static JButton quit = new JButton("Quit");
  public static void main (String[] args) {

    int x = (int)(java.lang.Math.random()*800);
    int y = (int)(java.lang.Math.random()*400);
    boolean loop = true;

    Draw t = new Draw(800, 400);
        t.clear(Color.blue);
        t.penUp();
        t.go(x, y);
        t.penDown();
        t.setColor(Color.yellow);
        t.spot(25,12);
    t.show();

    JFrame j = new JFrame("Control Panel");
    j.setSize(100,100); 
    Container c = j.getContentPane(); 
    c.setLayout(new FlowLayout()); 
    quit.addActionListener(new MyActionListener()); 
    c.add(quit); 
    j.show(); 
    j.addWindowListener(new MyWindowAdapter());
    int newx;
    int newy;
    while(loop)
    { 
     Random r = new Random(); 
    // fish movement
    }
    }
}

class MyActionListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
      System.out.println("Window closed...Exiting program!");
    System.exit(0);
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.