Hi everyone! I am learning java programming in my spare time and I'm having trouble with some parameters in showSaveDialog. I canīt get the save dialog to appear. Any suggestions will be helpful. Thanks in advance.
import java.io.*; import javafx.stage.FileChooser; import javax.swing.JOptionPane; public class main extends javax.swing.JFrame { private void saveToFile(){ try{ FileWriter writer=new FileWriter("save.nfo",false); writer.write(id.getText()); writer.write(System.getProperty("line.separator")); writer.write(name.getText()); writer.write(System.getProperty("line.separator")); writer.write(dep.getText()); writer.write(System.getProperty("line.separator")); writer.close(); JOptionPane.showMessageDialog(rootPane,"Success"); }catch(Exception e){ JOptionPane.showMessageDialog(rootPane,"Error"); } } private void saveActionPerformed(java.awt.event.ActionEvent evt) { //Set extension filter for text files. FileChooser fileChooser=new FileChooser(); FileChooser.ExtensionFilter extFilter=new FileChooser.ExtensionFilter("Only TXT files (*.txt)", "*.txt"); fileChooser.getExtensionFilters().add(extFilter); //Show save file dialog File file=fileChooser.showSaveDialog();//Don't know what parameter to use to make the dialog appear. No errors with 'null' but not helpful. if (file != null) { saveToFile(); } } }