For some time, I've been trying to open a different JFrame
AdminHome but it doesn't open. Even after I made a method of the JFrame
AdminHome hmscrn = new AdminHome();
All it does is to close my already completed frame and end the program completely instead of opening the home page
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");}
}