diff --git a/source/net/sourceforge/filebot/ui/Language.java b/source/net/sourceforge/filebot/ui/Language.java index 6ea1c5f8..522f4684 100644 --- a/source/net/sourceforge/filebot/ui/Language.java +++ b/source/net/sourceforge/filebot/ui/Language.java @@ -18,40 +18,40 @@ public class Language { private final String code; private final String name; - + public Language(String code, String name) { this.code = code; this.name = name; } - + public String getCode() { return code; } - + public String getName() { return name; } - + @Override public String toString() { return name; } - + public Locale toLocale() { return new Locale(getCode()); } - + @Override public Language clone() { return new Language(code, name); } - + public static final Comparator ALPHABETIC_ORDER = new Comparator() { @Override @@ -60,18 +60,18 @@ public class Language { } }; - + public static Language getLanguage(String code) { ResourceBundle bundle = ResourceBundle.getBundle(Language.class.getName()); try { return new Language(code, bundle.getString(code + ".name")); } catch (Exception e) { - return null; + return new Language(code, new Locale(code).getDisplayLanguage(Locale.ROOT)); } } - + public static List getLanguages(String... codes) { Language[] languages = new Language[codes.length]; @@ -82,7 +82,7 @@ public class Language { return asList(languages); } - + public static Language getLanguageByName(String name) { for (Language it : availableLanguages()) { if (name.equalsIgnoreCase(it.getName())) @@ -92,7 +92,7 @@ public class Language { return null; } - + public static String getISO3LanguageCodeByName(String languageName) { Language language = Language.getLanguageByName(languageName); if (language != null) { @@ -106,19 +106,19 @@ public class Language { return null; } - + public static List availableLanguages() { ResourceBundle bundle = ResourceBundle.getBundle(Language.class.getName()); return getLanguages(bundle.getString("languages.all").split(",")); } - + public static List commonLanguages() { ResourceBundle bundle = ResourceBundle.getBundle(Language.class.getName()); return getLanguages(bundle.getString("languages.common").split(",")); } - + public static List preferredLanguages() { Set codes = new LinkedHashSet(); diff --git a/source/net/sourceforge/filebot/ui/rename/RenamePanel.java b/source/net/sourceforge/filebot/ui/rename/RenamePanel.java index f5a48657..7f2822b3 100644 --- a/source/net/sourceforge/filebot/ui/rename/RenamePanel.java +++ b/source/net/sourceforge/filebot/ui/rename/RenamePanel.java @@ -235,7 +235,9 @@ public class RenamePanel extends JComponent { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - setIcon(ResourceManager.getFlagIcon(((Language) value).getCode())); + if (value != null) { + setIcon(ResourceManager.getFlagIcon(((Language) value).getCode())); + } return this; } });