我对代码有一个小问题。我只是希望如果在表单的构造函数部分中没有满足条件,则不会显示Jform。构造函数dispose(),return和setVisible(false)都可以正常工作。我曾尝试this.dispose();并返回;和this.setVisible(false);但表单仍然显示。用System.exit(0);它关闭了完整的应用程序。如果有人能帮助我,我会很感激。在构造函数中关闭Jform
public class OrderGUI extends javax.swing.JFrame {
public OrderGUI(Customer cust, Date dt, Time t) throws FileNotFoundException, IOException, ClassNotFoundException {
this();
if(condition)
{
/////do not initialize the Jform
}else{//// run rest of the code}
}
*“Closing Jform ..”* J2SE API中没有这样的类。不要像你的IDE那样说话。 –