我收到此错误:
cannot find symbol
symbol: method showMessageDialog(<anonymous javax.swing.AbstractAction>,java.lang.String,java.lang.String,int)
有人可以帮助我吗? 谢谢
exitAction = new
AbstractAction("Esci") {
public void actionPerformed(ActionEvent e) {
if (rcStatus ==1) {
JOptionPane.showMessageDialog(this,
"Thread running. Choose STOP before
exit",
"Error", JOptionPane.ERROR_MESSAGE);
}
else {
System.exit(0);}
}
};
exitAction.putValue(Action.NAME,
"Exit");
exitAction.putValue(Action.SHORT_DESCRIPTION,"Close");
最佳答案
JOptionPane
中没有具有该签名的方法。您确定您传入的 this
是 AbstractAction
,而不是 Component
。对于 showMessageDialog()
,these are your options .
我想你想要JOptionPane.showMessageDialog(Component parentComponent,
Object message,
String title,
int messageType)
。如果您没有合适的父组件可传入,请传递 null
而不是 this
:
JOptionPane.showMessageDialog(null, "Thread running. Choose STOP before exit", "Error", JOptionPane.ERROR_MESSAGE);
关于java - 消息对话框错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4670355/