Skip to content

Commit

Permalink
Bug Fix: Fixed system look and feel being in the list twice
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldenGnu committed Nov 14, 2021
1 parent 00b6a70 commit de4e0ba
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Expand Up @@ -41,7 +41,7 @@
public class ColorSettings {

public static enum PredefinedLookAndFeel {
DEFAULT(DialoguesSettings.get().lookAndFeelDefault(), UIManager.getSystemLookAndFeelClassName(), true),
DEFAULT(null, UIManager.getSystemLookAndFeelClassName(), true),
FLAT_LIGHT(DialoguesSettings.get().lookAndFeelFlatLight(), "com.formdev.flatlaf.FlatLightLaf"),
FLAT_INTELLIJ(DialoguesSettings.get().lookAndFeelFlatIntelliJ(), "com.formdev.flatlaf.FlatIntelliJLaf"),
FLAT_DARK(DialoguesSettings.get().lookAndFeelFlatDark(), "com.formdev.flatlaf.FlatDarkLaf"),
Expand All @@ -58,6 +58,17 @@ private PredefinedLookAndFeel(String name, String className) {
}

private PredefinedLookAndFeel(String name, String className, boolean selected) {
if (name == null) {
for (LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
if (laf.getClassName().equals(UIManager.getSystemLookAndFeelClassName())){
name = DialoguesSettings.get().lookAndFeelDefaultName(laf.getName());
break;
}
}
if (name == null) {
name = DialoguesSettings.get().lookAndFeelDefault();
}
}
this.name = name;
this.className = className;
this.selected = selected;
Expand Down
Expand Up @@ -225,6 +225,9 @@ public void run() {
}
//Installed LookAndFeels
for (LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
if (laf.getClassName().equals(UIManager.getSystemLookAndFeelClassName())){
continue; //Skip system LaF
}
JLookAndFeelMenuItem jMenuItem = new JLookAndFeelMenuItem(laf, jLookAndFeel, settingsDialog);
jLookAndFeel.add(jMenuItem);
lafButtonGroup.add(jMenuItem);
Expand Down
Expand Up @@ -119,6 +119,7 @@ public DialoguesSettings(final Locale locale) {
public abstract String theme();
public abstract String lookAndFeel();
public abstract String lookAndFeelDefault();
public abstract String lookAndFeelDefaultName(String name);
public abstract String lookAndFeelFlatLight();
public abstract String lookAndFeelFlatDark();
public abstract String lookAndFeelFlatIntelliJ();
Expand Down
Expand Up @@ -91,6 +91,7 @@ overwriteMsg=Overwrite customized colors?
theme=Colors
lookAndFeel=Look & Feel
lookAndFeelDefault=Default
lookAndFeelDefaultName=Default ({0})
lookAndFeelFlatLight=Flat Light
lookAndFeelFlatDark=Flat Dark
lookAndFeelFlatIntelliJ=Flat IntelliJ
Expand Down

0 comments on commit de4e0ba

Please sign in to comment.