diff --git a/src/main/java/sbu/javafx/MusicApp.java b/src/main/java/sbu/javafx/MusicApp.java index e6fd5e6..cdf066a 100644 --- a/src/main/java/sbu/javafx/MusicApp.java +++ b/src/main/java/sbu/javafx/MusicApp.java @@ -3,6 +3,7 @@ package sbu.javafx; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; +import javafx.scene.image.Image; import javafx.stage.Stage; public class MusicApp extends Application { @@ -13,6 +14,7 @@ public class MusicApp extends Application { getClass().getResource("App-view.fxml")); Scene scene = new Scene(loader.load()); stage.setTitle("Music Player"); + stage.getIcons().add(new Image("/sbu/images/default-cover.png")); stage.setScene(scene); stage.setResizable(false); stage.show(); diff --git a/src/main/java/sbu/javafx/MusicController.java b/src/main/java/sbu/javafx/MusicController.java index ebfae30..752201d 100644 --- a/src/main/java/sbu/javafx/MusicController.java +++ b/src/main/java/sbu/javafx/MusicController.java @@ -60,6 +60,10 @@ public class MusicController { private boolean isShuffle = false; private boolean isRepeat = false; + // theme button + @FXML private Button themeBtn; + private boolean isDarkMode = false; + // ========================================= Methods ============================================ public void initialize(){ // runs without calling libraryView.setItems(library); @@ -461,4 +465,18 @@ public class MusicController { libraryTabBtn.getStyleClass().remove("tab-active"); } + // theme controller + @FXML + public void handleThemeToggle() { + isDarkMode = !isDarkMode; + javafx.scene.Scene scene = themeBtn.getScene(); + + if (isDarkMode) { + scene.getRoot().getStyleClass().add("dark"); + themeBtn.setText("☀️"); + } else { + scene.getRoot().getStyleClass().remove("dark"); + themeBtn.setText("🌙"); + } + } } diff --git a/src/main/resources/sbu/javafx/App-view.fxml b/src/main/resources/sbu/javafx/App-view.fxml index 27dbace..ec85ecd 100644 --- a/src/main/resources/sbu/javafx/App-view.fxml +++ b/src/main/resources/sbu/javafx/App-view.fxml @@ -24,6 +24,12 @@ spacing="20" prefWidth="320"> + + +