diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/sbu/javafx/Launcher.java b/src/main/java/sbu/javafx/Launcher.java
index c288d10..ab853fa 100644
--- a/src/main/java/sbu/javafx/Launcher.java
+++ b/src/main/java/sbu/javafx/Launcher.java
@@ -4,5 +4,6 @@ import javafx.application.Application;
public class Launcher{
public static void main(String[] args) {
- // TODO: Launch the JavaFX application by calling Application.launch(Main.class) }
+ Application.launch(MusicApp.class, args);
+ }
}
diff --git a/src/main/java/sbu/javafx/MusicApp.java b/src/main/java/sbu/javafx/MusicApp.java
index a50badc..579d067 100644
--- a/src/main/java/sbu/javafx/MusicApp.java
+++ b/src/main/java/sbu/javafx/MusicApp.java
@@ -4,6 +4,7 @@ import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
+import javafx.scene.image.Image;
import java.io.IOException;
@@ -16,7 +17,7 @@ public class MusicApp extends Application {
Scene scene = new Scene(fxmlLoader.load());
stage.setTitle("Music Player");
stage.setScene(scene);
- //TODO: add icon to the stage
+ scene.getStylesheets().add(getClass().getResource("dark.css").toExternalForm());
stage.show();
}
diff --git a/src/main/java/sbu/javafx/MusicController.java b/src/main/java/sbu/javafx/MusicController.java
index 5da27a9..fe07c12 100644
--- a/src/main/java/sbu/javafx/MusicController.java
+++ b/src/main/java/sbu/javafx/MusicController.java
@@ -3,29 +3,82 @@ package sbu.javafx;
import javafx.fxml.FXML;
import javafx.event.ActionEvent;
import javafx.scene.control.Label;
+import javafx.scene.control.Button;
+import javafx.scene.control.ListView;
+import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBox;
+import javafx.stage.Stage;
+import java.util.ArrayList;
public class MusicController {
- // TODO: Define your UI components using the @FXML annotation.
-
- //TODO: Implement the logic to play a song. This method should update the UI to show which song is currently playing.
+ @FXML
+ private Label nowPlayingLabel;
@FXML
- public void handlePlayAction() {
- //Update labels, change button icons, etc.
+ private Button playBtn1, playBtn2, playBtn3;
+ private final ArrayList playlist = new ArrayList<>();
+ private boolean isDark = true;
+
+ @FXML
+ public void toggleTheme() {
+ Scene scene = playBtn1.getScene();
+ scene.getStylesheets().clear();
+ if (isDark) {
+ scene.getStylesheets().add(getClass().getResource("light.css").toExternalForm());
+ } else {
+ scene.getStylesheets().add(getClass().getResource("dark.css").toExternalForm());
+ }
+ isDark = !isDark;
}
+ private void resetPlayButtons() {
+ playBtn1.setText("Play");
+ playBtn1.setStyle(null);
+ playBtn2.setText("Play");
+ playBtn2.setStyle(null);
+ playBtn3.setText("Play");
+ playBtn3.setStyle(null);
+ }
+ @FXML
+ public void handlePlayAction(ActionEvent event) {
+ resetPlayButtons();
+ Button clicked = (Button) event.getSource();
+ clicked.setText("Playing");
+ clicked.setStyle("-fx-background-color: #4CAF50; -fx-text-fill: white;");
- //TODO: Logic to add a specific song to the user's playlist.
-
+ if (clicked == playBtn1) {
+ nowPlayingLabel.setText("Now Playing: Blinding Lights - The Weeknd");
+ } else if (clicked == playBtn2) {
+ nowPlayingLabel.setText("Now Playing: Bohemian Rhapsody - Queen");
+ } else if (clicked == playBtn3) {
+ nowPlayingLabel.setText("Now Playing: Hotel California - Eagles");
+ }
+ }
public void addToPlaylist(String songName) {
- //Add the song to a list or update a ListView.
+ playlist.add(songName);
+ System.out.println("Added to playlist: " + songName);
}
-
- // TODO:This method should open a new window or change the current scene to display the "Playlist" page.
-
+ @FXML
public void openPlaylistWindow() {
- //Create a new stage and show the playlist UI.
+ Stage playlistStage = new Stage();
+ playlistStage.setTitle("My Playlist");
+
+ ListView listView = new ListView<>();
+ listView.getItems().addAll(playlist);
+
+ VBox root = new VBox(listView);
+ Scene scene = new Scene(root, 300, 400);
+ playlistStage.setScene(scene);
+ playlistStage.show();
}
+ @FXML
+ public void handleAdd1() { addToPlaylist("Blinding Lights - The Weeknd"); }
+
+ @FXML
+ public void handleAdd2() { addToPlaylist("Bohemian Rhapsody - Queen"); }
+
+ @FXML
+ public void handleAdd3() { addToPlaylist("Hotel California - Eagles"); }
+
}
diff --git a/src/main/resources/sbu/javafx/App-view.fxml b/src/main/resources/sbu/javafx/App-view.fxml
index 306c8d3..e2bfef1 100644
--- a/src/main/resources/sbu/javafx/App-view.fxml
+++ b/src/main/resources/sbu/javafx/App-view.fxml
@@ -1,8 +1,44 @@
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/sbu/javafx/dark.css b/src/main/resources/sbu/javafx/dark.css
new file mode 100644
index 0000000..38f8c61
--- /dev/null
+++ b/src/main/resources/sbu/javafx/dark.css
@@ -0,0 +1,51 @@
+.root {
+ -fx-background-color: #1a1a2e;
+ -fx-font-family: "Segoe UI", sans-serif;
+}
+
+.header-title {
+ -fx-font-size: 24px;
+ -fx-font-weight: bold;
+ -fx-text-fill: #ffffff;
+}
+
+.now-playing {
+ -fx-font-size: 14px;
+ -fx-text-fill: #aaaaaa;
+}
+
+.song-card {
+ -fx-background-color: #2d2d44;
+ -fx-padding: 15;
+ -fx-background-radius: 10;
+ -fx-effect: dropshadow(gaussian, rgba(0,0,0,0.3), 5, 0, 0, 2);
+}
+
+.song-title {
+ -fx-font-size: 16px;
+ -fx-font-weight: bold;
+ -fx-text-fill: #ffffff;
+}
+
+.song-artist {
+ -fx-text-fill: #888888;
+}
+
+.play-btn {
+ -fx-background-color: #2196F3;
+ -fx-text-fill: white;
+}
+
+.play-btn:disabled {
+ -fx-opacity: 0.6;
+}
+
+.add-btn {
+ -fx-background-color: #4a4a6a;
+ -fx-text-fill: white;
+}
+
+.view-playlist-btn {
+ -fx-background-color: #9C27B0;
+ -fx-text-fill: white;
+}
\ No newline at end of file
diff --git a/src/main/resources/sbu/javafx/light.css b/src/main/resources/sbu/javafx/light.css
new file mode 100644
index 0000000..07ddaae
--- /dev/null
+++ b/src/main/resources/sbu/javafx/light.css
@@ -0,0 +1,47 @@
+.root {
+ -fx-background-color: #f5f5f5;
+ -fx-font-family: "Segoe UI", sans-serif;
+}
+
+.header-title {
+ -fx-font-size: 24px;
+ -fx-font-weight: bold;
+ -fx-text-fill: #1a1a2e;
+}
+
+.now-playing {
+ -fx-font-size: 14px;
+ -fx-text-fill: #555555;
+}
+
+.song-card {
+ -fx-background-color: #ffffff;
+ -fx-padding: 15;
+ -fx-background-radius: 10;
+ -fx-effect: dropshadow(gaussian, rgba(0,0,0,0.1), 5, 0, 0, 2);
+}
+
+.song-title {
+ -fx-font-size: 16px;
+ -fx-font-weight: bold;
+ -fx-text-fill: #000000;
+}
+
+.song-artist {
+ -fx-text-fill: #888888;
+}
+
+.play-btn {
+ -fx-background-color: #2196F3;
+ -fx-text-fill: white;
+}
+
+.add-btn {
+ -fx-background-color: #e0e0e0;
+ -fx-text-fill: #1a1a2e;
+}
+
+.view-playlist-btn {
+ -fx-background-color: #9C27B0;
+ -fx-text-fill: white;
+}
\ No newline at end of file