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..503b0b3 100644
--- a/src/main/java/sbu/javafx/MusicApp.java
+++ b/src/main/java/sbu/javafx/MusicApp.java
@@ -13,10 +13,14 @@ public class MusicApp extends Application {
public void start(Stage stage) throws IOException
{
FXMLLoader fxmlLoader = new FXMLLoader(MusicApp.class.getResource("App-view.fxml"));
- Scene scene = new Scene(fxmlLoader.load());
+ Scene scene = new Scene(fxmlLoader.load(),500,450);
+
+ MusicController musicController = fxmlLoader.getController();
+ musicController.setStage(stage);
+
stage.setTitle("Music Player");
stage.setScene(scene);
- //TODO: add icon to the stage
+
stage.show();
}
diff --git a/src/main/java/sbu/javafx/MusicController.java b/src/main/java/sbu/javafx/MusicController.java
index 5da27a9..d7d75f4 100644
--- a/src/main/java/sbu/javafx/MusicController.java
+++ b/src/main/java/sbu/javafx/MusicController.java
@@ -1,31 +1,79 @@
package sbu.javafx;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
import javafx.fxml.FXML;
-import javafx.event.ActionEvent;
+import javafx.scene.Scene;
import javafx.scene.control.Label;
-import javafx.scene.input.MouseEvent;
+import javafx.scene.control.ListView;
import javafx.scene.layout.VBox;
+import javafx.stage.Stage;
public class MusicController {
- // TODO: Define your UI components using the @FXML annotation.
+ @FXML
+ private Label nowPlayingLabel;
- //TODO: Implement the logic to play a song. This method should update the UI to show which song is currently playing.
+ private final ObservableList playlist =
+ FXCollections.observableArrayList();
+
+ private Stage stage;
+
+ public void setStage(Stage stage) {
+ this.stage = stage;
+ }
@FXML
- public void handlePlayAction() {
- //Update labels, change button icons, etc.
+ public void playSong1() {
+ handlePlayAction("Blinding Lights");
}
- //TODO: Logic to add a specific song to the user's playlist.
+ @FXML
+ public void playSong2() {
+ handlePlayAction("Shape of You");
+ }
+
+ @FXML
+ public void playSong3() {
+ handlePlayAction("Believer");
+ }
+
+ public void handlePlayAction(String songName) {
+ nowPlayingLabel.setText("Now Playing: " + songName);
+ }
+
+ @FXML
+ public void addSong1() {
+ addToPlaylist("Blinding Lights");
+ }
+
+ @FXML
+ public void addSong2() {
+ addToPlaylist("Shape of You");
+ }
+
+ @FXML
+ public void addSong3() {
+ addToPlaylist("Believer");
+ }
public void addToPlaylist(String songName) {
- //Add the song to a list or update a ListView.
+ playlist.add(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.
+
+ Label title = new Label("My Playlist");
+
+ ListView listView = new ListView<>();
+ listView.setItems(playlist);
+
+ VBox root = new VBox(10);
+ root.getChildren().addAll(title, listView);
+
+ Scene playlistScene = new Scene(root, 400, 300);
+
+ stage.setScene(playlistScene);
}
-}
+}
\ No newline at end of file
diff --git a/src/main/resources/sbu/javafx/App-view.fxml b/src/main/resources/sbu/javafx/App-view.fxml
index 306c8d3..c1af170 100644
--- a/src/main/resources/sbu/javafx/App-view.fxml
+++ b/src/main/resources/sbu/javafx/App-view.fxml
@@ -1,8 +1,48 @@
+
+
+
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file