All pastes #753678 Raw Edit

Miscellany

public java v1 · immutable
#753678 ·published 2007-10-29 13:13 UTC
rendered paste body
import java.awt.*;import javax.swing.*;import java.awt.event.*;public class Evolution extends JFrame implements ActionListener {	private PlayPanel myPlayPanel;	public Individual[] individuals;	private Timer tim = new Timer(20, this);				public Evolution () {				setTitle("Myror");		setSize(600,600);		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);		Container c = getContentPane();		c.setLayout(new BorderLayout());		myPlayPanel = new PlayPanel();		c.add(myPlayPanel, BorderLayout.CENTER);		tim.start();		setVisible(true);				individuals = new Individual[100];		for(int i=0;i<100;i++) {			individuals[i] = new Individual(100,200,0, false);		}	}		public void actionPerformed (ActionEvent e) {		for(int i=0;i<100;i++) {				individuals[i].step();			}		repaint();	}		public static void main(String[] args) {		new Evolution();	}		public class PlayPanel extends JPanel {		public void paintComponent(Graphics g) {			super.paintComponent(g);			g.setColor(Color.black);			g.drawRect(0, 0, 600, 600);			g.fillRect(0, 0, 600, 600);			for(int i=0;i<100;i++) {					individuals[i].draw(g);				}		}	}}Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException	at Evolution.actionPerformed(Evolution.java:32)	at javax.swing.Timer.fireActionPerformed(Unknown Source)	at javax.swing.Timer$DoPostEvent.run(Unknown Source)	at java.awt.event.InvocationEvent.dispatch(Unknown Source)	at java.awt.EventQueue.dispatchEvent(Unknown Source)	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)	at java.awt.EventDispatchThread.run(Unknown Source)