如何使用try和catch在周围的代码之后打开其他不同的Jframe

时间:2016-06-21 13:57:53

标签: java swing awt

有一段时间以来,我一直在尝试打开其他JFrame AdminHome ,但它并未打开。甚至在我制作了JFrame

的方法之后
AdminHome hmscrn = new AdminHome();

所有这一切都是关闭我已经完成的框架并完全结束程序而不是打开主页

private void addBttnActionPerformed(java.awt.event.ActionEvent evt) {                                        
    try{
    String sql = "insert into maintainsite (siteID,country,state,city,revenue,date,capacity) values (?,?,?,?,?,?,?)";
    pst=conn.prepareStatement(sql);
    pst.setString(1, (String) siteID.getSelectedItem());
    pst.setString(2, (String) country.getSelectedItem());
    pst.setString(3, (String) state.getSelectedItem());
    pst.setString(4, (String) city.getSelectedItem());
    pst.setString(5, revenuelb.getText());
    pst.setString(6, ((JTextField) date.getDateEditor().getUiComponent()).getText());
    pst.setString(7, capacitylb.getText());


    pst.execute();
      int replying = JOptionPane.showConfirmDialog(null, "information saved! return to home page?","successful", JOptionPane.YES_NO_OPTION);
    if (replying == JOptionPane.YES_OPTION) {
      JOptionPane.showMessageDialog(null, "got it!");
      close();
    AdminHome hmscrn = new AdminHome();
    hmscrn.setVisible(true);
    }
      else {
       JOptionPane.showMessageDialog(null, "close program!");

    close();
    }


    }
    catch(Exception e){JOptionPane.showMessageDialog(null, "please complete your selection and try again");}
} 

1 个答案:

答案 0 :(得分:-2)

我看到了自己的错误。

在属性方面的实际JFrame选项中,您必须将defaultCloseOperationOpenSAML3 resource not found 'default-config.xml' in OSGi container更改为EXIT ON CLOSE

我希望我也能帮助别人经历同样的事情。