次のコードのメソッドを使用している場合wait()
、次の例外をスローします
Exception in thread "AWT-EventQueue-0" java.lang.IllegalMonitorStateException
コードは次のとおりです。
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");
}
}
実際、私はjDialogクラスのオブジェクトを呼び出しており、ダイアログオブジェクトが最初に完了してから、上記のコードに通知する必要があります。そのクラスでnotify()をすでに指定しました。誰かが問題とその解決策を教えてもらえますか?-前もって感謝します