From e6accec2915c48c509fa09d23fc5aa7b5618c88d Mon Sep 17 00:00:00 2001 From: kske Date: Sat, 21 Dec 2019 08:06:05 +0100 Subject: [PATCH] Fixed layout of SettingsPanel in SettingsScreen --- .../envoy/client/ui/settings/SettingsScreen.java | 12 ++++++++++-- .../ui/settings/ThemeCustomizationPanel.java | 14 +++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/envoy/client/ui/settings/SettingsScreen.java b/src/main/java/envoy/client/ui/settings/SettingsScreen.java index 65cacac..740750d 100644 --- a/src/main/java/envoy/client/ui/settings/SettingsScreen.java +++ b/src/main/java/envoy/client/ui/settings/SettingsScreen.java @@ -60,7 +60,7 @@ public class SettingsScreen extends JDialog { setBounds(10, 10, 450, 650); getContentPane().setLayout(new BorderLayout()); { - // Content pane + // ContentPane GridBagLayout gbl_contentPanel = new GridBagLayout(); gbl_contentPanel.columnWidths = new int[] { 1, 1 }; @@ -71,6 +71,14 @@ public class SettingsScreen extends JDialog { getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(gbl_contentPanel); + // Constraints for the settings panel + GridBagConstraints gbc_panel = new GridBagConstraints(); + gbc_panel.fill = GridBagConstraints.BOTH; + gbc_panel.gridx = 1; + gbc_panel.gridy = 0; + gbc_panel.anchor = GridBagConstraints.PAGE_START; + gbc_panel.insets = insets; + options.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); options.addListSelectionListener((listSelectionEvent) -> { if (!listSelectionEvent.getValueIsAdjusting()) { @@ -86,7 +94,7 @@ public class SettingsScreen extends JDialog { settingsPanel = panels.get(option).getDeclaredConstructor().newInstance(); // Add selected settings panel - contentPanel.add(settingsPanel); + contentPanel.add(settingsPanel, gbc_panel); revalidate(); repaint(); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException diff --git a/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java b/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java index ed9c5db..57780f3 100644 --- a/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java +++ b/src/main/java/envoy/client/ui/settings/ThemeCustomizationPanel.java @@ -34,7 +34,7 @@ public class ThemeCustomizationPanel extends SettingsPanel { private JComboBox themes = new JComboBox<>(themeArray); private Theme temporaryTheme, selectedTheme; - private final int space = 5; + private final Insets insets = new Insets(5, 5, 5, 5); private static final Logger logger = EnvoyLog.getLogger(ThemeCustomizationPanel.class.getSimpleName()); @@ -46,14 +46,6 @@ public class ThemeCustomizationPanel extends SettingsPanel { public ThemeCustomizationPanel() { temporaryTheme = new Theme("temporaryTheme", Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme())); - // Theme content - GridBagConstraints gbc_themeContent = new GridBagConstraints(); - gbc_themeContent.fill = GridBagConstraints.BOTH; - gbc_themeContent.gridx = 1; - gbc_themeContent.gridy = 0; - gbc_themeContent.anchor = GridBagConstraints.PAGE_START; - gbc_themeContent.insets = new Insets(space, space, space, space); - GridBagLayout gbl_themeLayout = new GridBagLayout(); gbl_themeLayout.columnWidths = new int[] { 1, 1 }; @@ -80,7 +72,7 @@ public class ThemeCustomizationPanel extends SettingsPanel { gbc_themes.gridx = 0; gbc_themes.gridy = 0; gbc_themes.anchor = GridBagConstraints.NORTHWEST; - gbc_themes.insets = new Insets(space, space, space, space); + gbc_themes.insets = insets; add(themes, gbc_themes); @@ -96,7 +88,7 @@ public class ThemeCustomizationPanel extends SettingsPanel { gbc_colorsPanel.gridy = 1; gbc_colorsPanel.gridwidth = 2; gbc_colorsPanel.anchor = GridBagConstraints.NORTHWEST; - gbc_colorsPanel.insets = new Insets(space, 0, 0, 0); + gbc_colorsPanel.insets = insets; add(colorsPanel, gbc_colorsPanel);