我對代碼有一個小問題。我只是希望如果在表單的構造函數部分中沒有滿足條件,則不會顯示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那樣說話。 –