From 4ef0b3352cb29befffb4669553d67dada3f5ab87 Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Mon, 23 Dec 2019 15:54:55 +0100 Subject: [PATCH] Fixed weird toggle switch programming from @CyB3rC0nN0R --- .../java/envoy/client/ui/PrimaryToggleSwitch.java | 12 +++++++++--- src/main/java/envoy/client/ui/settings/General.java | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/envoy/client/ui/PrimaryToggleSwitch.java b/src/main/java/envoy/client/ui/PrimaryToggleSwitch.java index d6a23cc..6ea198d 100644 --- a/src/main/java/envoy/client/ui/PrimaryToggleSwitch.java +++ b/src/main/java/envoy/client/ui/PrimaryToggleSwitch.java @@ -40,6 +40,7 @@ public class PrimaryToggleSwitch extends JButton { setFocusPainted(false); setContentAreaFilled(false); + state = settingsItem.get(); addActionListener((evt) -> { state = !state; settingsItem.set(state); revalidate(); repaint(); }); } @@ -47,8 +48,13 @@ public class PrimaryToggleSwitch extends JButton { public void paintComponent(Graphics g) { g.setColor(state ? Color.GREEN : Color.LIGHT_GRAY); g.fillRect(0, 0, getWidth(), getHeight()); - g.setColor(state ? Color.LIGHT_GRAY - : Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getInteractableBackgroundColor()); - g.fillRect(0, getWidth() / 2, getWidth(), getHeight()); + + g.setColor(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getInteractableBackgroundColor()); + + if (state) { + g.fillRect(25, 0, 25, 25); + } else { + g.fillRect(0, 0, 25, 25); + } } } \ No newline at end of file diff --git a/src/main/java/envoy/client/ui/settings/General.java b/src/main/java/envoy/client/ui/settings/General.java index 9b6339a..59a6345 100644 --- a/src/main/java/envoy/client/ui/settings/General.java +++ b/src/main/java/envoy/client/ui/settings/General.java @@ -81,5 +81,5 @@ public class General extends SettingsPanel { } @Override - public ActionListener getOkButtonAction() { return null; } + public ActionListener getOkButtonAction() { return (evt) -> {}; } } \ No newline at end of file