When I am using the wait()
method in the following code its throwing the following Exeption
Exception in thread "AWT-EventQueue-0" java.lang.IllegalMonitorStateException
The code is as follows:
private void newMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
newFileChooser = new JFileChooser();
int returnVal = newFileChooser.showSaveDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
filename = newFileChooser.getSelectedFile();
JFrame mainFrame = NetSimApp.getApplication().getMainFrame();
networktype = new NetType(mainFrame);
networktype.setLocationRelativeTo(mainFrame);
NetSimApp.getApplication().show(networktype);
try {
this.wait();
} catch (InterruptedException ex) {
Logger.getLogger(NetSimView.class.getName()).log(Level.SEVERE, null, ex);
}
if (!NetType.validip) {
statusTextArea.append("File not created:Select Network Type.\n");
}
newNodeMenuItem.setEnabled(true);
} else {
newNodeMenuItem.setEnabled(false);
statusTextArea.append("File not created:Access cancelled by user.\n");
}
}
Actually I am calling the object of a jDialog class and i want that the dialog object should complete first and then it should notify the above given code. I've already specified notify() in that class. Can anyone tell me whats the problem and its solution. -Thanks in advance