Changed colors management in the displaying of the themes settings

screen.
This commit is contained in:
DieGurke 2019-12-14 12:54:32 +01:00
parent 89b75b00c8
commit a0e72a6e56

View File

@ -138,11 +138,6 @@ public class SettingsScreen extends JDialog {
Theme theme = Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()); Theme theme = Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme());
options.setSelectionForeground(theme.getUserNameColor());
options.setSelectionBackground(theme.getSelectionColor());
options.setForeground(theme.getUserNameColor());
options.setBackground(theme.getCellColor());
GridBagConstraints gbc_optionsList = new GridBagConstraints(); GridBagConstraints gbc_optionsList = new GridBagConstraints();
gbc_optionsList.fill = GridBagConstraints.BOTH; gbc_optionsList.fill = GridBagConstraints.BOTH;
gbc_optionsList.gridx = 0; gbc_optionsList.gridx = 0;
@ -164,9 +159,6 @@ public class SettingsScreen extends JDialog {
GridBagLayout gbl_themeLayout = new GridBagLayout(); GridBagLayout gbl_themeLayout = new GridBagLayout();
themeContent.setForeground(theme.getUserNameColor());
themeContent.setBackground(theme.getCellColor());
gbl_themeLayout.columnWidths = new int[] { 1, 1 }; gbl_themeLayout.columnWidths = new int[] { 1, 1 };
gbl_themeLayout.rowHeights = new int[] { 1, 1 }; gbl_themeLayout.rowHeights = new int[] { 1, 1 };
gbl_themeLayout.columnWeights = new double[] { 1.0, 1.0 }; gbl_themeLayout.columnWeights = new double[] { 1.0, 1.0 };
@ -174,8 +166,6 @@ public class SettingsScreen extends JDialog {
themeContent.setLayout(gbl_themeLayout); themeContent.setLayout(gbl_themeLayout);
themes.setBackground(theme.getUserNameColor());
themes.setForeground(theme.getBackgroundColor());
themes.setSelectedItem(Settings.getInstance().getCurrentTheme()); themes.setSelectedItem(Settings.getInstance().getCurrentTheme());
themes.addItemListener(new ItemListener() { themes.addItemListener(new ItemListener() {
@ -300,8 +290,6 @@ public class SettingsScreen extends JDialog {
contentPanel.revalidate(); contentPanel.revalidate();
contentPanel.repaint(); contentPanel.repaint();
// TODO: Create new Theme
} catch (Exception e) { } catch (Exception e) {
logger.info("New theme couldn't be created! " + e); logger.info("New theme couldn't be created! " + e);
e.printStackTrace(); e.printStackTrace();
@ -397,8 +385,8 @@ public class SettingsScreen extends JDialog {
themeContent.setForeground(theme.getUserNameColor()); themeContent.setForeground(theme.getUserNameColor());
themeContent.setBackground(theme.getCellColor()); themeContent.setBackground(theme.getCellColor());
// themes // themes
themes.setBackground(theme.getUserNameColor()); themes.setBackground(theme.getBackgroundColor());
themes.setForeground(theme.getBackgroundColor()); themes.setForeground(getInvertedColor(theme.getBackgroundColor()));
createNewThemeButton.setBackground(theme.getInteractableBackgroundColor()); createNewThemeButton.setBackground(theme.getInteractableBackgroundColor());
createNewThemeButton.setForeground(theme.getInteractableForegroundColor()); createNewThemeButton.setForeground(theme.getInteractableForegroundColor());
@ -517,7 +505,7 @@ public class SettingsScreen extends JDialog {
String name, int yIndex) { String name, int yIndex) {
textPane.setFont(new Font("Arial", Font.PLAIN, 14)); textPane.setFont(new Font("Arial", Font.PLAIN, 14));
textPane.setBackground(theme.getBackgroundColor()); textPane.setBackground(theme.getBackgroundColor());
textPane.setForeground(theme.getUserNameColor()); textPane.setForeground(getInvertedColor(theme.getBackgroundColor()));
textPane.setText(name); textPane.setText(name);
textPane.setEditable(false); textPane.setEditable(false);
@ -532,11 +520,11 @@ public class SettingsScreen extends JDialog {
System.out.println(color.getRGB()); System.out.println(color.getRGB());
// TODO: When Theme changed in same settings screen, color variable doesnt // TODO: When Theme changed in same settings screen, color variable doesnt
// update. // update.
temporaryTheme.setColor(yIndex, newColor); temporaryTheme.setColor(yIndex, newColor);
colorChanged = true; colorChanged = true;
createNewThemeButton.setEnabled(true); createNewThemeButton.setEnabled(true);
} }
button.setBackground(newColor); button.setBackground(newColor);
} catch (Exception e) { } catch (Exception e) {
logger.info("An error occured while opening Color Chooser: " + e); logger.info("An error occured while opening Color Chooser: " + e);
@ -544,9 +532,16 @@ public class SettingsScreen extends JDialog {
} }
}); });
panel.add(textPane);panel.add(button);panel.setBackground(theme.getCellColor());panel.setAlignmentX(Component.LEFT_ALIGNMENT); panel.add(textPane);
panel.add(button);
panel.setBackground(theme.getCellColor());
panel.setAlignmentX(Component.LEFT_ALIGNMENT);
colorsPanel.add(panel); colorsPanel.add(panel);
} }
private Color getInvertedColor(Color color) {
return new Color(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue());
}
} }