Graphics2D would allow gradiants, masking , rotation, and things like that. Any reason why you want the extra graphics functionality? Have you got other Graphics2D? Are you painting to an Image offscreen?And, you say background. Applet, JApplet, or a member of javax.swing.JComponent? You can paint directly on a JFrame. With Swing a little care needed because Swing itself is an animation cycle.
so, if using Swing components
import javax.swing.Timer;
int delay = 1000; //milliseconds
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
myJPanel.setBackGround( color[ index ] );
index = (index == 1) ? 0 : 1;
}
};
new Timer(delay, taskPerformer).start();