Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Everytime I click cancel, instead of going back to the main screen for the progr

ID: 3830108 • Letter: E

Question

Everytime I click cancel, instead of going back to the main screen for the program it exits the whole program. How do I make it that it doesn't exit completely but just take user back to main screen?

Here is code:

panel.add(field2);

int result = JOptionPane.showConfirmDialog(null, panel, "Submit a Ticket",

JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

  

   

  

  

if (result == JOptionPane.OK_OPTION) {

       try {

                Class.forName("com.mysql.jdbc.Driver").newInstance();

Explanation / Answer

if(result==JOptionPane.CANCEL_OPTION){

centerPanel.dispose();//closes the currently opened center pane

mainScreen.setVisible(true);//main screen gets focus

}

Hope this helps!!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote