Fixed weird toggle switch programming from @CyB3rC0nN0R
This commit is contained in:
		| @@ -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); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -81,5 +81,5 @@ public class General extends SettingsPanel { | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	public ActionListener getOkButtonAction() { return null; } | ||||
| 	public ActionListener getOkButtonAction() { return (evt) -> {}; } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 DieGurke
					DieGurke