Drop_of_Rain
asked on
adding JOptionPane to closing the window
How would I transfer this JoptionPane to my standard window closing? There won't be a button just the x at the top of the window.
public windowVerify(){
JButton close = new JButton("Close");
close.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
JOptionPane dlg = new JOptionPane();
if(JOptionPane.OK_OPTION== dlg.showCo nfirmDialo g(null,"Wa nt to exit ?","Message",JOptionPane.Y ES_NO_OPTI ON ))
System.exit(0);
}
});
getContentPane ().setLayout(new FlowLayout());
getContentPane ().add(close);
}
public void windowClosing(WindowEvent e)
{ // Opens windowClosing method
System.exit(0);
} // Closes windowClosing method
}); // Closes addWindowListener method
public windowVerify(){
JButton close = new JButton("Close");
close.addMouseListener(new
public void mouseClicked(MouseEvent e){
JOptionPane dlg = new JOptionPane();
if(JOptionPane.OK_OPTION==
System.exit(0);
}
});
getContentPane ().setLayout(new FlowLayout());
getContentPane ().add(close);
}
public void windowClosing(WindowEvent e)
{ // Opens windowClosing method
System.exit(0);
} // Closes windowClosing method
}); // Closes addWindowListener method
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER