From 233e3bcb83e791fd752ad79b260c97dc7ce3fd38 Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Sat, 7 Dec 2019 13:31:08 +0100 Subject: [PATCH] Fixes themes list display bug and error when loading client with custom theme --- src/main/java/envoy/client/Settings.java | 1 + src/main/java/envoy/client/ui/SettingsScreen.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/envoy/client/Settings.java b/src/main/java/envoy/client/Settings.java index 21a1afa..e84e647 100644 --- a/src/main/java/envoy/client/Settings.java +++ b/src/main/java/envoy/client/Settings.java @@ -76,6 +76,7 @@ public class Settings { if(obj instanceof HashMap) themes = (Map) obj; } catch (IOException | ClassNotFoundException e) { themes = new HashMap<>(); + currentTheme = "dark"; e.printStackTrace(); } diff --git a/src/main/java/envoy/client/ui/SettingsScreen.java b/src/main/java/envoy/client/ui/SettingsScreen.java index a003972..6d5c94d 100644 --- a/src/main/java/envoy/client/ui/SettingsScreen.java +++ b/src/main/java/envoy/client/ui/SettingsScreen.java @@ -8,7 +8,6 @@ import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; -import java.awt.LayoutManager; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.Arrays; @@ -48,8 +47,7 @@ public class SettingsScreen extends JDialog { private JPanel buttonPane = new JPanel(); private JPanel themeContent = new JPanel(); - private String[] themeArray = { Settings.getInstance().getThemes().get("dark").getThemeName(), - Settings.getInstance().getThemes().get("light").getThemeName() }; + private String[] themeArray = Settings.getInstance().getThemes().keySet().toArray(new String[0]); private JComboBox themes = new JComboBox(themeArray); private GridBagConstraints gbc_themeContent = new GridBagConstraints(); @@ -198,10 +196,16 @@ public class SettingsScreen extends JDialog { themeContent.add(themes, gbc_themes); - colorsPanel.setLayout((LayoutManager) new BoxLayout(colorsPanel, BoxLayout.Y_AXIS)); + colorsPanel.setLayout(new BoxLayout(colorsPanel, BoxLayout.Y_AXIS)); colorsPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - buildCustomizeElement(new JPanel(), new JButton(), new JTextPane(), theme, theme.getBackgroundColor(), "Background", 1); + buildCustomizeElement(new JPanel(), + new JButton(), + new JTextPane(), + theme, + theme.getBackgroundColor(), + "Background", + 1); buildCustomizeElement(new JPanel(), new JButton(), new JTextPane(), theme, theme.getCellColor(), "Cells", 2); buildCustomizeElement(new JPanel(), new JButton(),