2

I'm trying to make a dialog that allows selecting a file name and file type. While the dialog is opening, if I change the file type, the file name does not update the extension automatically corresponding file type.

Here is my example code:

public void exportFile() {
    String exportPath = "";
    FileDialog fdlg = new FileDialog(getShell(), SWT.SAVE);
    fdlg.setFilterPath(exportPath);
    fdlg.setText("Export Dialog");
    fdlg.setFilterExtensions(new String[] { "*.mp3", "*.mp4" });
    fdlg.setFilterNames(new String[] { "Audio (*.mp3)", "Video (*.mp4)" });
    fdlg.setFileName("project.mp3"); // default name and file type
    
    exportPath = fdlg.open();
}

When fdlg.open() is executed, the dialog is opened, in the dialog, is there a way if I change the file type to "Video (*.mp4)", the file name will be changed to "project.mp4" automatically?

Thanks for your help!

James
  • 21
  • 1

0 Answers0