code: public static void setFileBrowsingOnWidgets( JTextField pathTextField, JButton browseButton, String[] allowedExtensions,
              Runnable postRunnable ) {
          FileFilter filter = null;
          if (allowedExtensions != null) {
              filter = new FileFilter(){
  
                  @Override
                  public String getDescription() {
                      return Arrays.toString(allowedExtensions);
                  }
  
                  @Override
                  public boolean accept( File f ) {
                      if (f.isDirectory()) {
                          return true;
                      }
                      String name = f.getName();
                      for( String ext : allowedExtensions ) {
                          if (name.toLowerCase().endsWith(ext.toLowerCase())) {
                              return true;
                          }
                      }
                      return false;
                  }
              };
          }
          FileFilter _filter = filter;
          browseButton.addActionListener(e -> {
              File lastFile = GuiUtilities.getLastFile();
              File[] res = showOpenFilesDialog(browseButton, "Select file", false, lastFile, _filter);
              if (res != null && res.length == 1) {
                  String absolutePath = res[0].getAbsolutePath();
                  pathTextField.setText(absolutePath);
                  setLastPath(absolutePath);
                  if (postRunnable != null) {
                      postRunnable.run();
                  }
              }
          });
      }
docs: Adds to a textfield and button the necessary to browse for a file.
  
  @param pathTextField
  @param browseButton
  @param allowedExtensions