日期:2014-05-20 浏览次数:20746 次
package lianxi; import javax.swing.JDialog; import java.awt.event.WindowEvent; public class TestJDialog extends JDialog { public TestJDialog() { } public static void main(String args[]) { timeListener lis; TestJDialog tj= new TestJDialog(); tj.setVisible(true); lis= new timeListener(tj); Thread thread= new Thread(lis); thread.start(); } } class timeListener implements Runnable{ private TestJDialog testJDialog; public timeListener(TestJDialog testJDialog) { this.testJDialog=testJDialog; } public void run() { for(long i=0;i<10000;i++)//延时 { System.out.println("i==="+i); } //问题:在此处添加代码,将testJDialog关闭,如何实现 } }