I have a java code that responds to a button click event. The Parent JFrame which has the button Disappears when i try to pop up a message box , So what's the problem ?
Here are the codes :
private void TestConnectionButtonActionPerformed(java.awt.event.ActionEvent evt) {
InitDatabaseObject();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run()
{
if(Database.ConnectToDatabase())
{
JOptionPane.showMessageDialog(null,"Connection succeeded");
}else{
JOptionPane.showMessageDialog(null,"Connection failed");
}
}
});
Database.CloseDbConnection();
}
Help me plz ..
JOptionPane.showMessageDialog(null,"Connection succeeded");
try to use reference to your JFrame (which you don't want to disappear) instead of null
JOptionPane.showMessageDialog(frame,"Connection succeeded");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With