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!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.