import javax.swing.JFrame;
public class Driver00
{
public static void main(String[] args)
{
/*Create a frame (outside box) and write what text
will be displayed as the frame title*/
JFrame frame = new JFrame("Casino Blackjack");
JFrame frame2 = new JFrame("Rules and Information");
//allows JFrame to be maximiazed on open
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame2.setExtendedState(JFrame.MAXIMIZED_BOTH);
//give frame a size
// frame.setSize(2000,2000);
//set location on the computer screen will frame appear
//frame.setLocation(200, 150);
//use this so when you press X in corner, frame will close
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Add your panel to the frame. name must match Panel class name
frame.setContentPane(new PanelProject());
frame2.setContentPane(new Rules());
// always include
frame.setVisible(true);
frame2.setVisible(true);
}
}
This is the application that launches my GUI, my problem is that if I don't comment out the line frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
and I click the x
button, it closes both frame
and frame2
. It works the other way too. If I dont comment out out the same line that has frame
instead of frame2
and I click the x
button, it closes both frames.
I would like to be able to close on frame or the other without having to worry about both frames being closed.