Tank Java2D Tutorial

This is just a trivial example of how to do java2d programming. It's basically a really crude demonstration of basic java2D concepts.

Don't let the "Tank" name fool you, this isn't anything neat. I cobbled this together as a first, really rough attempt at making a typical tank game, but I never got past the rudimentary stage. If it took over the entire screen when it ran, it'd be a bouncing ball screen-saver.

The things missing include:

Maybe one of these days. Meanwhile, it's simple enough that I thought it'd be useful as (very) basic intro into java2d topics.

Classes

There are two class files:

Specifically, the TankSimulator class:

Meanwhile, the Tank class:

The Graphics2D Stuff

TankSimulator extends JComponent. Because TankSimulator extends JComponent, I can add it to a JFrame's content pane. Fortunately, that's just what I do in TankSimulator's main() method: