Reputation: 35
I use this line to show my ConfirmDialog
int yn = JOptionPane.showConfirmDialog(frame.getParent(), scrollPane, "stuffs",
JOptionPane.OK_CANCEL_OPTION);
In that ConfirmDialog I have a button which calls a server using a actionListener, when the connection is broken I have a check which terminates the function. But i can for the love of god not figure out how to terminate the ConfirmDialog at the same time.
How can I solve this problem while still using ConfirmDialog?
Upvotes: 0
Views: 731
Reputation: 35
The awnser to my question is partly awnserd by you both, but this is the solution wich worked for me!
JOptionPane pane = new JOptionPane(tempviewAssistChanges, JOptionPane.PLAIN_MESSAGE);
final JDialog dialogrr = pane.createDialog(frame.getParent(), "Result report");
dialogrr.setVisible(true);
final ActionListener action = new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(loggedout)
{
dialogrr.dispose();
}
}
};
Upvotes: 0
Reputation: 444
You could use setVisible(false) or dispose() method
JOptionPane pane=newJOptionPane(frame.getParent(),scrollPane,"stuffs",JOptionPane.OK_CANCEL_OPTION);
pane.dispose(); //or pane.setVisible(false);
Upvotes: 1