Look at the Swing Timer class. There is sample code in the API doc.