I want my code to paint a panel, wait 1 second. Edit the panel by executing the function nextGen(); and repaint the panel. I want this function to happen 5 times. The problem is, everytime I try to do a try/catch thing with thread.sleep(), it "skips" over repaint, does nextGen(); and sleeps. Please help!
button3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
for(int i = 0;i<5;i++) {
try {
Thread.sleep(1000);
nextGen();
panel.repaint();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//System.exit(0);
}
});