Java Code Examples for javax.swing.JFileChooser.setLocale()

The following are Jave code examples for showing how to use setLocale() of the javax.swing.JFileChooser class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: javaportfolio   File: PortfolioDocument.java   Source Code and License Vote up 6 votes
public static File selectPortfolioDirectory(JFrame frame) {

		// Create a file chooser
		JFileChooser fc = new JFileChooser();
		fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
		fc.setLocale(new Locale("fi", "FI"));
		int returnVal = fc.showOpenDialog(frame);
		if (returnVal == JFileChooser.APPROVE_OPTION) {
			File file = fc.getSelectedFile();
			return file;
		}
		return null;
	}
 
Example 2
Project: sbc-qsystem   File: Uses.java   Source Code and License Vote up 6 votes
/**
 * Вызывает диалог выбора файла.
 *
 * @param parent Относительно чего показывать форму диалога.
 * @param title Заголовок диалогового окна.
 * @param description Описание фильтра, например "Файлы XML(*.xml)".
 * @param extension Фильтр по расширению файлов, например "xml".
 * @return Полное имя файла или null если не выбрали.
 */
public static String getFileName(Component parent, String title, String description,
    String extension) {
    final JFileChooser fileChooser = new JFileChooser();
    fileChooser.setLocale(Locales.getInstance().getLangCurrent());
    fileChooser.resetChoosableFileFilters();
    final FileNameExtensionFilter filter = new FileNameExtensionFilter(description, extension);
    fileChooser.setFileFilter(filter);
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setDialogTitle(title);

    if (fileChooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
        if (fileChooser.getSelectedFile().exists()) {
            return fileChooser.getSelectedFile().getAbsolutePath();
        }
    }
    return null;
}
 
Example 3
Project: bddproject   File: File.java   Source Code and License Vote up 5 votes
/**
* Use the readFile method with a JFileChooser interface to select the file to convert.
* @return The file convert in String
*/
public static String selectAndReadFile(){
    String ret = "";
    JFileChooser chooser = new JFileChooser("../ws/samples");
    java.util.Locale.setDefault(java.util.Locale.ENGLISH);
    chooser.setLocale(java.util.Locale.ENGLISH);
    chooser.setLocale(java.util.Locale.getDefault());
    chooser.updateUI();
    chooser.setFileFilter(new FileNameExtensionFilter("SQL file (*.sql)", "sql"));
    int returnVal = chooser.showOpenDialog(null);
    if(returnVal == JFileChooser.APPROVE_OPTION){
        ret = readFile(chooser.getSelectedFile().getAbsolutePath());
    }
    return ret;
}
 
Example 4
Project: bddproject   File: File.java   Source Code and License Vote up 5 votes
/**
* Use the writeFile method with a JFileChooser interface to select where you want to save your file.
* @param data The String to save in a file.
*/
public static void selectAndWriteFile(String data){
    JFileChooser chooser = new JFileChooser("../ws/samples");
    java.util.Locale.setDefault(java.util.Locale.ENGLISH);
    chooser.setLocale(java.util.Locale.ENGLISH);
    chooser.setLocale(java.util.Locale.getDefault());
    chooser.updateUI();
    chooser.setFileFilter(new FileNameExtensionFilter("SQL file (*.sql)", "sql"));

    int returnVal = chooser.showSaveDialog(null);
    if(returnVal == JFileChooser.APPROVE_OPTION){
        writeFile(chooser.getSelectedFile().getAbsolutePath()+".sql", data);
    }
}