diff --git a/.idea/misc.xml b/.idea/misc.xml index 001e756..0c04b52 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ - + \ No newline at end of file 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..956770a 100644 --- a/src/main/java/sbu/javafx/Launcher.java +++ b/src/main/java/sbu/javafx/Launcher.java @@ -5,4 +5,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); + + }} \ No newline at end of file diff --git a/src/main/java/sbu/javafx/MusicApp.java b/src/main/java/sbu/javafx/MusicApp.java index a50badc..3066f98 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; @@ -17,6 +18,9 @@ public class MusicApp extends Application { stage.setTitle("Music Player"); stage.setScene(scene); //TODO: add icon to the stage + stage.getIcons().add( + new Image(MusicApp.class.getResourceAsStream("icon.png")) + ); stage.show(); } diff --git a/src/main/java/sbu/javafx/MusicController.java b/src/main/java/sbu/javafx/MusicController.java index 5da27a9..3f61704 100644 --- a/src/main/java/sbu/javafx/MusicController.java +++ b/src/main/java/sbu/javafx/MusicController.java @@ -3,29 +3,85 @@ package sbu.javafx; import javafx.fxml.FXML; import javafx.event.ActionEvent; import javafx.scene.control.Label; +import javafx.geometry.Insets; +import javafx.scene.Scene; +import javafx.scene.control.Button; import javafx.scene.input.MouseEvent; import javafx.scene.layout.VBox; +import javafx.stage.Stage; +import javafx.scene.control.ListView; +import java.util.ArrayList; + public class MusicController { // TODO: Define your UI components using the @FXML annotation. + @FXML + private Label nowPlayingLabel; + + private final ArrayList playlist = new ArrayList<>(); + //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() { + public void handlePlayAction(ActionEvent event) { //Update labels, change button icons, etc. - } + Button button = (Button) event.getSource(); + String songName = button.getUserData().toString(); + + nowPlayingLabel.setText("Now Playing : " + songName); + + +} //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. + if (!playlist.contains(songName)) { + playlist.add(songName); + } + } + + @FXML + public void addSong1() { + addToPlaylist("Shape Of You"); + } + + @FXML + public void addSong2() { + addToPlaylist("Believer"); + } + + @FXML + public void addSong3() { + addToPlaylist("Perfect"); } // 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 stage = new Stage(); + + VBox root = new VBox(15); + root.setPadding(new Insets(20)); + + Label title = new Label("My Playlist"); + + ListView listView = new ListView<>(); + listView.getItems().addAll(playlist); + + Button closeButton = new Button("Close"); + closeButton.setOnAction(e -> stage.close()); + + root.getChildren().addAll(title, listView, closeButton); + + Scene scene = new Scene(root, 350, 400); + + stage.setTitle("Playlist"); + stage.setScene(scene); + stage.show(); } } diff --git a/src/main/resources/sbu/javafx/App-view.fxml b/src/main/resources/sbu/javafx/App-view.fxml index 306c8d3..caaf352 100644 --- a/src/main/resources/sbu/javafx/App-view.fxml +++ b/src/main/resources/sbu/javafx/App-view.fxml @@ -1,8 +1,81 @@ - + + + + + - + + + + +