Here you can find the source of makeFileNameExtensionFilter(String[] extensions)
public static FileNameExtensionFilter makeFileNameExtensionFilter(String[] extensions)
//package com.java2s; //License from project: Open Source License import javax.swing.filechooser.FileNameExtensionFilter; public class Main { public static FileNameExtensionFilter makeFileNameExtensionFilter(String[] extensions) { if (extensions == null) return null; int numExtensions = 0; for (int ii = 0; ii < extensions.length; ++ii) if (extensions[ii] != null) numExtensions = numExtensions + 1; String[] nne = new String[numExtensions]; int iext = 0; String extensionDesc = ""; for (int ii = 0; ii < extensions.length; ++ii) { if (extensions[ii] != null) { nne[iext] = extensions[ii]; if (iext == 0) extensionDesc = extensionDesc + "*." + extensions[ii]; if (iext > 0) extensionDesc = extensionDesc + ", *." + extensions[ii]; iext = iext + 1;// w w w. ja v a 2 s .c om } } if (numExtensions == 1) return new FileNameExtensionFilter(extensionDesc, nne[0]); if (numExtensions == 2) return new FileNameExtensionFilter(extensionDesc, nne[0], nne[1]); if (numExtensions == 3) return new FileNameExtensionFilter(extensionDesc, nne[0], nne[1], nne[2]); if (numExtensions >= 4) return new FileNameExtensionFilter(extensionDesc, nne[0], nne[1], nne[2], nne[3]); return null; } }