public static File getFilepath(String themeName) { if (themeName == null) { return null; } File configDirPath = FileUtil.getEditorThemeConfigDir(); String themeFileName = themeName + EDITOR_THEME_PROPERTIES_FILE_EXT; return new File(configDirPath, themeFileName); }
private JComboBox getThemeComboBox() { if (themeComboBox == null) { final String fileExt = EditorThemePropertiesManager.getFileExt(); File[] themeFiles = FileUtil.getEditorThemeConfigDir().listFiles(new java.io.FileFilter() { public boolean accept(File filepath) { return filepath.getName().endsWith(fileExt); } }); List<String> themeNames = new ArrayList<String>(); for (File file : themeFiles) { String themeName = file.getName(); themeName = themeName.substring(0, themeName.lastIndexOf(fileExt)); themeNames.add(themeName); } themeComboBox = new JComboBox(themeNames.toArray()); themeComboBox.addActionListener(eventHandler); } return themeComboBox; }
File file = EditorThemePropertiesManager.getFilepath(themeName); JFileChooser saveThemeDialog = new JFileChooser(FileUtil.getEditorThemeConfigDir()); saveThemeDialog.setDialogTitle("Save Theme"); saveThemeDialog.setSelectedFile(file);