Where do you call initGame()
? Since the timer is started in this method, if you never call it, the Timer never starts.
Regarding:
when I try to run the initGame method it tells me I can't reference it from a static context
You need to show us this attempt. Usually this means that you're trying to call the method on the class not on the instance.
i.e.,
public Test2() {
setDefaultCloseOperation(EXIT_ON_CLOSE);
setMinimumSize(new Dimension(800, 600));
paintPanel = new PaintPanel();
getContentPane().add(paintPanel, BorderLayout.CENTER);
pack();
paintPanel.initGame();
}
Edit
You state:
PaintPanel.initGame();
You can't do this. You can't call a non-static method on a class as if it's a static method. Instead it must be called on the instance as I show above. So the answer to the question,
How can I initialize a repaint timer from a static context?
Is that you don't. You initialize it from a non-static context.
Note that you shouldn't declare the paintPanel variable as a JPanel since you need to call the initGame()
method on it which is not a method of JPanel. Instead declare it as a PaintPanel variable.
Edit 2
regarding:
I get a cannot find symbol error referring to initGame.
Please re-read the last paragraph above this edit.