I need help in the running of the following Java program.
I want the main program to pause running after it displays a new JFrame form and resume after the new window is closed ( or Next button is clicked ) .
So The 10 Forms should come sequentially after I press the next button not altogether at once!
MainClass.java
public class MainClass {
void Run()
{
    for(int i=0;i<10;i++)
        new NewForm().setVisible(true);
}
public static void main (String[] args)
{
    new MainClass().Run();
}
}
NewForm.java
public class NewForm extends javax.swing.JFrame {
    public NewForm() {
        initComponents();
    }
    @SuppressWarnings("unchecked")
    private void initComponents() {
        jButton1 = new javax.swing.JButton();
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        jButton1.setText("Next");
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(155, 155, 155)
                .addComponent(jButton1)
                .addContainerGap(190, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(131, 131, 131)
                .addComponent(jButton1)
                .addContainerGap(146, Short.MAX_VALUE))
        );
        pack();
    }
   public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewForm().setVisible(true);
            }
        });
    }
    private javax.swing.JButton jButton1;              
}
 
     
    