JFileChooser has bug with some filenames?

210 views Asked by At

I'm using Ubuntu, and I tried to use JFileChooser in my java application, but it seems that it has problems with file names that can be described with this regex:

.*\[.*\].*

Which means file names that contain "[" and "]". Dialog just rejects to select such files for saving. Am I the only one to have this problem? What could be the problem?

I used oracle jre and open-jdk jre.

edit:

private void btnSelectSrcMouseClicked(java.awt.event.MouseEvent evt) {                                          
       int result = filechooser.showDialog(this,"Select");

       if(result == JFileChooser.APPROVE_OPTION){
           sourceFile = filechooser.getSelectedFile();
           this.txtFilePath.setText(sourceFile.getAbsolutePath());
       }
    }                                         

private void btnSelectDestMouseClicked(java.awt.event.MouseEvent evt) {                                           
        int result = filechooser.showDialog(this,"Select");

       if(result == JFileChooser.APPROVE_OPTION){
           destinationFile = filechooser.getSelectedFile();
           this.txtDestPath.setText(destinationFile.getAbsolutePath());
       }
    }

This is the code. Used one instance of JFileChooser for two purposes, first when user clicks one button dialog pops up and user selects file. Then after clicking another button same dialog pops up, and user selects destination file that might not exist to that moment. And if file name is like discribed above, then after clicking "Select" button (I made mistake, I didn't open JFileChooser as Save dialog) file type in the bottom of dialog gets same value as file name text field. After clicking "Select" few more times it does nothing.

0

There are 0 answers