问题是当我关闭我的GUI窗口时我想运行最后一个方法(例如printList()),但我无法做到这一点。这是我的主要方法关于覆盖主要方法中的GUI的run()方法
public static void main(String args[]) {
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
patientTest2 screen = new patientTest2();
screen.setVisible(true);
screen.setResizable(false);
} catch (FileNotFoundException ex) {
Logger.getLogger(patientTest2.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
patientTest2是我的JFrame类。我假设如果我在} catch (FileNotFoundException ex) {
之前放printList()
它应该工作,并最终将我的列表打印到一个文件,但它不。如果你能帮助我解释为什么,我会很高兴。
它工作,我感到非常愚蠢因为我记得我添加windowsClosed方法,它没有工作,所以我没有尝试windowsClosing。顺便谢谢你的帮助:) – quartaela 2012-02-29 15:32:26