I want to create a small Swing app. It has 2 JFrame
s. First JFrame
has a button and when I click this button, the second JFrame
will show . The second JFrame
show in 2 seconds then it dispose. I want this action will run many time! I wrote this code, but it does not work:
private void btnStudyActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
for( int i = 0 ; i< 10 ; i++){
Show s = new Show();
s.setVisible(true);
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
}
s.dispose();
}
}
Please give me a solution.