diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..8306744
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ 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..a3ffd1f 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);
+ }
}
diff --git a/src/main/java/sbu/javafx/MusicApp.java b/src/main/java/sbu/javafx/MusicApp.java
index a50badc..863e864 100644
--- a/src/main/java/sbu/javafx/MusicApp.java
+++ b/src/main/java/sbu/javafx/MusicApp.java
@@ -4,7 +4,9 @@ import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
+import javafx.scene.image.Image;
+import java.awt.*;
import java.io.IOException;
public class MusicApp extends Application {
@@ -16,7 +18,13 @@ 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("light.css").toExternalForm());
+ stage.setWidth(1100);
+ stage.setHeight(500);
+
+ Image icon = new Image(getClass().getResourceAsStream("icon.png"));
+ stage.getIcons().add(icon);
+
stage.show();
}
diff --git a/src/main/java/sbu/javafx/MusicController.java b/src/main/java/sbu/javafx/MusicController.java
index 5da27a9..c417ce9 100644
--- a/src/main/java/sbu/javafx/MusicController.java
+++ b/src/main/java/sbu/javafx/MusicController.java
@@ -1,31 +1,148 @@
package sbu.javafx;
-import javafx.fxml.FXML;
import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
import javafx.scene.control.Label;
-import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.HBox;
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.
+ public Label Name1;
+ public Label Singer1;
+ public Button AddToPlaylist1;
+ public Button play1;
+
+ public Label Name2;
+ public Label Singer2;
+ public Button AddToPlaylist2;
+ public Button play2;
+
+ public Label Name3;
+ public Label Singer3;
+ public Button AddToPlaylist3;
+ public Button play3;
+
+ public HBox song1;
+ public HBox song2;
+ public HBox song3;
+ public HBox header;
+ public HBox playingBox;
+
+ boolean isDark = false;
+ Button currentPlayingSong = null;
+ public Label nowPlayingSong;
+ public Button themeToggle;
+ public Button PlayListButton;
+
+ ArrayList playlist = new ArrayList<>();
+ boolean onPlaylist1 = false;
+ boolean onPlaylist2 = false;
+ boolean onPlaylist3 = false;
- //TODO: Implement the logic to play a song. This method should update the UI to show which song is currently playing.
@FXML
- public void handlePlayAction() {
- //Update labels, change button icons, etc.
+ public void handlePlayAction(ActionEvent actionEvent) {
+ Button button = (Button) actionEvent.getSource();
+
+ if(currentPlayingSong == button) {
+ currentPlayingSong.setText("Play");
+ nowPlayingSong.setText(" ");
+ currentPlayingSong = null;
+ return;
+ }
+
+ if(currentPlayingSong != null) {
+ currentPlayingSong.setText("Play");
+ }
+
+
+ currentPlayingSong = button;
+ currentPlayingSong.setText("Playing...");
+
+ if(currentPlayingSong == play1) {
+ nowPlayingSong.setText(Name1.getText() + " | " + Singer1.getText());
+ }
+ else if(currentPlayingSong == play2) {
+ nowPlayingSong.setText(Name2.getText() + " | " + Singer2.getText());
+ }
+ else if (currentPlayingSong == play3) {
+ nowPlayingSong.setText(Name3.getText() + " | " + Singer3.getText());
+ }
}
- //TODO: Logic to add a specific song to the user's playlist.
- public void addToPlaylist(String songName) {
- //Add the song to a list or update a ListView.
+ @FXML
+ public void addToPlaylist(ActionEvent event) {
+
+ Button button = (Button) event.getSource();
+
+ if(button == AddToPlaylist1 && !onPlaylist1) {
+ playlist.add(song1);
+ AddToPlaylist1.setText("On Playlist");
+ onPlaylist1 = true;
+ }
+ else if(button == AddToPlaylist2 && !onPlaylist2) {
+ playlist.add(song2);
+ AddToPlaylist2.setText("On Playlist");
+ onPlaylist2 = true;
+ }
+ else if(button == AddToPlaylist3 && !onPlaylist3) {
+ playlist.add(song3);
+ AddToPlaylist3.setText("On Playlist");
+ onPlaylist3 = true;
+ }
}
- // TODO:This method should open a new window or change the current scene to display the "Playlist" page.
+ public void openPlaylistWindow(ActionEvent event) {
- public void openPlaylistWindow() {
- //Create a new stage and show the playlist UI.
+ Button button = (Button) event.getSource();
+
+ Stage stage = (Stage) button.getScene().getWindow();
+
+ stage.setTitle("Playlist");
+ VBox root = new VBox();
+
+ if(!playlist.isEmpty()){
+ root.getChildren().add(header);
+ root.getChildren().addAll(playlist);
+ root.getChildren().add(playingBox);
+ }
+ else {
+ Label label = new Label("Your playlist is empty.");
+ if(!isDark)
+ label.setStyle("-fx-font-size: 24px;");
+ else
+ label.setStyle("-fx-font-size: 24px; ; -fx-text-fill: #e0e0e0;");
+ root.getChildren().add(label);
+ }
+
+
+ Scene scene = new Scene(root);
+ if(!isDark)
+ scene.getStylesheets().add(getClass().getResource("light.css").toExternalForm());
+ else
+ scene.getStylesheets().add(getClass().getResource("dark.css").toExternalForm());
+
+ stage.setScene(scene);
+ }
+
+ @FXML
+ public void toggleTheme() {
+ isDark = !isDark;
+ themeToggle.getScene().getStylesheets().clear();
+ if(isDark) {
+ themeToggle.getScene().getStylesheets().add(getClass().getResource("dark.css").toExternalForm());
+ themeToggle.setText("Switch to Light Mode");
+ }
+ else {
+ themeToggle.getScene().getStylesheets().add(getClass().getResource("light.css").toExternalForm());
+ themeToggle.setText("Switch to Dark Mode");
+ }
}
}
diff --git a/src/main/resources/sbu/javafx/App-view.fxml b/src/main/resources/sbu/javafx/App-view.fxml
index 306c8d3..ec20d3d 100644
--- a/src/main/resources/sbu/javafx/App-view.fxml
+++ b/src/main/resources/sbu/javafx/App-view.fxml
@@ -1,8 +1,50 @@
-
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/sbu/javafx/dark.css b/src/main/resources/sbu/javafx/dark.css
new file mode 100644
index 0000000..5f709f4
--- /dev/null
+++ b/src/main/resources/sbu/javafx/dark.css
@@ -0,0 +1,96 @@
+
+.root {
+ -fx-font-family: "Segoe UI", "Inter", "Arial";
+ -fx-background-color: #0f172a;
+ -fx-padding: 20;
+}
+
+
+.main-container {
+ -fx-background-color: #111827;
+ -fx-background-radius: 18;
+ -fx-padding: 20;
+ -fx-spacing: 14;
+ -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.35), 20, 0.2, 0, 6);
+}
+
+
+.header-row {
+ -fx-alignment: center-left;
+ -fx-padding: 0 0 10 0;
+ -fx-spacing: 14;
+}
+
+
+.header-row .label {
+ -fx-text-fill: #f8fafc;
+ -fx-font-size: 14px;
+ -fx-font-weight: bold;
+}
+
+
+.track-row {
+ -fx-background-color: #1f2937;
+ -fx-background-radius: 14;
+ -fx-padding: 10 14;
+ -fx-spacing: 14;
+ -fx-alignment: center-left;
+}
+
+.track-row:hover {
+ -fx-background-color: #273244;
+ -fx-cursor: hand;
+}
+
+
+.track-row .label {
+ -fx-text-fill: #cbd5e1;
+ -fx-font-size: 13px;
+}
+
+
+.button {
+ -fx-background-color: #3b82f6;
+ -fx-text-fill: white;
+ -fx-background-radius: 10;
+ -fx-padding: 8 14;
+ -fx-font-size: 13px;
+ -fx-cursor: hand;
+ -fx-border-width: 0;
+}
+
+.button:hover {
+ -fx-background-color: #2563eb;
+}
+
+.button:pressed {
+ -fx-background-color: #1d4ed8;
+}
+
+
+.playlist-button {
+ -fx-background-color: #22c55e;
+ -fx-text-fill: white;
+ -fx-background-radius: 10;
+ -fx-padding: 10 20;
+ -fx-font-size: 14px;
+ -fx-font-weight: bold;
+}
+.playlist-button:hover {
+ -fx-background-color: #16a34a;
+}
+.playlist-button:pressed {
+ -fx-background-color: #15803d;
+}
+
+
+
+.footer-row {
+ -fx-alignment: center-left;
+ -fx-padding: 16 0 0 0;
+ -fx-spacing: 10;
+}
+
+.footer-row .label {
+ -fx-text-fill: #94a3b8;
+}
diff --git a/src/main/resources/sbu/javafx/icon.png b/src/main/resources/sbu/javafx/icon.png
new file mode 100644
index 0000000..a3caca5
Binary files /dev/null and b/src/main/resources/sbu/javafx/icon.png differ
diff --git a/src/main/resources/sbu/javafx/light.css b/src/main/resources/sbu/javafx/light.css
new file mode 100644
index 0000000..a629e32
--- /dev/null
+++ b/src/main/resources/sbu/javafx/light.css
@@ -0,0 +1,98 @@
+
+.root {
+ -fx-font-family: "Segoe UI", "Inter", "Arial";
+ -fx-background-color: #f8fafc;
+ -fx-padding: 20;
+}
+
+
+.main-container {
+ -fx-background-color: #ffffff;
+ -fx-background-radius: 18;
+ -fx-padding: 20;
+ -fx-spacing: 14;
+ -fx-effect: dropshadow(gaussian, rgba(15, 23, 42, 0.08), 18, 0.2, 0, 6);
+}
+
+
+.header-row {
+ -fx-alignment: center-left;
+ -fx-padding: 0 0 10 0;
+ -fx-spacing: 14;
+}
+
+
+.header-row .label {
+ -fx-text-fill: #0f172a;
+ -fx-font-size: 14px;
+ -fx-font-weight: bold;
+}
+
+
+.track-row {
+ -fx-background-color: #f8fafc;
+ -fx-background-radius: 14;
+ -fx-padding: 10 14;
+ -fx-spacing: 14;
+ -fx-alignment: center-left;
+}
+
+.track-row:hover {
+ -fx-background-color: #eef2ff;
+ -fx-cursor: hand;
+}
+
+
+.track-row .label {
+ -fx-text-fill: #334155;
+ -fx-font-size: 13px;
+}
+
+
+.button {
+ -fx-background-color: #2563eb;
+ -fx-text-fill: white;
+ -fx-background-radius: 10;
+ -fx-padding: 8 14;
+ -fx-font-size: 13px;
+ -fx-cursor: hand;
+ -fx-border-width: 0;
+}
+
+.button:hover {
+ -fx-background-color: #1d4ed8;
+}
+
+.button:pressed {
+ -fx-background-color: #1e40af;
+}
+
+.playlist-button {
+ -fx-background-color: #22c55e;
+ -fx-text-fill: white;
+ -fx-background-radius: 10;
+ -fx-padding: 10 20;
+ -fx-font-size: 14px;
+ -fx-font-weight: bold;
+}
+.playlist-button:hover {
+ -fx-background-color: #16a34a;
+}
+.playlist-button:pressed {
+ -fx-background-color: #15803d;
+}
+
+
+#PlayListButton:pressed {
+ -fx-background-color: #047857;
+}
+
+.footer-row {
+ -fx-alignment: center-left;
+ -fx-padding: 16 0 0 0;
+ -fx-spacing: 10;
+}
+
+.footer-row .label {
+ -fx-text-fill: #64748b;
+}