我在运行以下 Java 程序时需要帮助。我希望主程序在显示新JFrame
窗体后暂停运行,并在新窗口关闭(或单击下一步按钮)后恢复运行。
所以这 10 个表格应该在我按下下一个按钮之后依次出现,而不是一次全部按下!
主类.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();
}
}
新窗体.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;
}