Draw Multiple objects in java?
<p>Hey guy's im making a java game where yellow blocks appear randomly across the game screen and you have to collect them. These objects are created from one class and i was wondering if there is a way to draw all of them?</p>

<p>This is the code that spawns them:</p>

<pre><code>package OurGame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

import javax.swing.*;

public class coins extends JPanel implements ActionListener {
Timer t;
coin c;

    public coins() {
        t = new Timer(1000,this);
        t.start();
    }

    public void actionPerformed(ActionEvent e) {
        System.out.println("1 Second");

        Random rx = new Random();
        Random ry = new Random();

        c = new coin(rx.nextInt(640),ry.nextInt(480));
    }

}
</code></pre>

<p>and this is the code for the coin itself.</p>

<pre><code>package OurGame;

import java.awt.Image;

import javax.swing.ImageIcon;

public class coin {
Image coin;

int x,y;
        public coin(int x1, int y1) {

            ImageIcon i = new ImageIcon("C:/coin.png");
            coin = i.getImage();

            x = x1;
            y = y1;
        }

        public Image getImage(){
            return coin;
        }

        public int getX(){
            return x;
        }

        public int getY() {
            return y;
        }
}
</code></pre>

<p>Would be awesome if you could help.</p>
