package spacefront;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JComponent;

public class SpacePanel extends JComponent implements Observer {

    private static final long serialVersionUID = 1L;

    Spacefront space;

    public SpacePanel(Spacefront space) {
        this.space = space;
        setPreferredSize(space.getSize());
        setMinimumSize(space.getSize());
        space.addObserver(this);
    }

    @Override
    public void update(Observable o, Object arg) {
        repaint();
    }

    @Override
    public void paintComponent(Graphics graphics) {
        graphics.setColor(Color.BLACK);
        graphics.fillRect(0, 0, getWidth(), getHeight());
        Graphics2D g = (Graphics2D) graphics;
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                           RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
                           RenderingHints.VALUE_STROKE_PURE);
        g.translate(getWidth() / 2, getHeight() / 2);
        double size = space.getHomeSize();
        Shape home = new Ellipse2D.Double(-size, -size, size * 2, size * 2);
        g.setColor(Color.GREEN);
        g.fill(home);

        g.setColor(Color.WHITE);
        g.setStroke(new BasicStroke(2));
        for (Meteoroid m : space.getMeteoroids()) {
            g.draw(m.get());
        }

        g.setColor(Color.RED);
        for (Shot s : space.getShots()) {
            g.fill(s.get());
        }
    }
}

@@ -301,16 +301,41 @@
 server;%0A
+import java.util.Random;%0A
 import j
@@ -482,32 +482,250 @@
 L;%0A%0A    
-Spacefront space
+private static final int STAR_COUNT = 100;%0A    private static final Color%5B%5D STAR_COLORS = %7B%0A        Color.WHITE, Color.GRAY, Color.LIGHT_GRAY%0A    %7D;%0A%0A    private Spacefront space;%0A    private int starseed = (int) (Math.random() * 100)
 ;%0A%0A    p
@@ -1164,24 +1164,54 @@
 tHeight());%0A
+        paintStars(graphics);%0A
         Grap
@@ -1750,16 +1750,96 @@
 lor.
-WHITE
+RED
 );%0A
+        for (Shot s : space.getShots()) %7B%0A            g.fill(s.get());%0A        %7D%0A%0A
     
@@ -1945,12 +1945,49 @@
   g.
-draw
+setColor(Color.BLACK);%0A            g.fill
 (m.g
@@ -1989,39 +1989,32 @@
 l(m.get());%0A    
-    %7D%0A%0A
         g.setCol
@@ -2026,55 +2026,290 @@
 lor.
-RED);%0A        for (Shot s : space.getShots()) %7B
+WHITE);%0A            g.draw(m.get());%0A        %7D%0A    %7D%0A%0A    private void paintStars(Graphics g) %7B%0A        Random stars = new Random(starseed);%0A        for (int i = 0; i %3C STAR_COUNT; i++) %7B%0A            int x = stars.nextInt(getWidth());%0A            int y = stars.nextInt(getHeight());
 %0A   
@@ -2315,36 +2315,115 @@
           g.
-fill(s.get()
+setColor(STAR_COLORS%5Bstars.nextInt(STAR_COLORS.length)%5D);%0A            g.drawLine(x, y, x, y
 );%0A        %7D

Add a starfield.