how do i clear my frame screen in java?
问题 I am making a brick game. I want the screen to get clear after every 0.1 second so that i can redraw every thing on the frame screen. Is there any way to directly clear the frame screen without any event occurence?? 回答1: You should override public void paint(Graphics g) and do all your drawing in there. Then you start a timer, which calls repaint(); Here is a basic example: public class MainFrame extends JFrame { int x = -1; int inc; public MainFrame() { Timer timer = new Timer(10, new