I am using netbeans for developing java dextop application,I have created a JFilechooser
which will let user to save a new file created.
But the this int returnVal = newFileChooser.showSaveDialog(this);
line of the following code gives this error:
method showSaveDialog in javax.swing.JFileChooser cannot be applied to given types required: java.awt.Component found: netsim.NetSimView
here class name is NetSimView
and source package is 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.");
}
}
How to fix this error?