// this is the basics of gui stuff import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.*; public class J07UserControl extends Component implements Runnable, MouseListener, MouseMotionListener { private ArrayList points; private JFrame mainFrame; // this is called a constructor (look up the term) public J07UserControl() { points = new ArrayList(); points.add(new ColouredPoint(5,5,new Color((float)Math.random(),(float)Math.random(),(float)Math.random()))); points.add(new ColouredPoint(20,20,new Color((float)Math.random(),(float)Math.random(),(float)Math.random()))); mainFrame = new JFrame(); mainFrame.getContentPane().setLayout(new FlowLayout()); mainFrame.getContentPane().add(this); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.addMouseMotionListener(this); this.addMouseListener(this); mainFrame.pack(); mainFrame.setVisible(true); } public static void main(String[] args) { J07UserControl j07 = new J07UserControl(); Thread t = new Thread(j07); t.start(); } public void run() { while(mainFrame.isVisible()) { try{ this.repaint(); Thread.sleep(50); }catch(Exception e){} } } public Dimension getPreferredSize() { return new Dimension(400,400); } public void paint(Graphics g) { g.setColor(Color.BLACK); g.fillRect(0,0,400,400); for(int i=0;i