我使用NetBeans開發java dextop應用程序,我創建了一個JFilechooser
,它將讓用戶保存創建的新文件。netbeans中的JFilechooser問題
但是這int returnVal = newFileChooser.showSaveDialog(this);
線以下代碼給出了這樣的錯誤:
method showSaveDialog in javax.swing.JFileChooser cannot be applied to given types required: java.awt.Component found: netsim.NetSimView
這裏的類名是NetSimView
和源包netsim
private void newMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
newFileChooser=new JFileChooser();
int returnVal = newFileChooser.showSaveDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = newFileChooser.getSelectedFile();
} else {
System.out.println("File access cancelled by user.");
}
}
如何解決這個問題?