Fixes themes list display bug and error when loading client with custom

theme
This commit is contained in:
DieGurke 2019-12-07 13:31:08 +01:00
parent 78be2e01a7
commit 233e3bcb83
2 changed files with 10 additions and 5 deletions

View File

@ -76,6 +76,7 @@ public class Settings {
if(obj instanceof HashMap) themes = (Map<String, Theme>) obj;
} catch (IOException | ClassNotFoundException e) {
themes = new HashMap<>();
currentTheme = "dark";
e.printStackTrace();
}

View File

@ -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<String> themes = new JComboBox<String>(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(),