From 1de7da14ac652d1d052aba646647b689731296b9 Mon Sep 17 00:00:00 2001 From: Zahra Gharagozloo Mazlaghan Date: Tue, 2 Jun 2026 13:50:22 +0330 Subject: [PATCH 1/3] App_view completed. --- .idea/misc.xml | 2 +- .idea/vcs.xml | 6 ++ src/main/java/sbu/javafx/Launcher.java | 6 +- src/main/java/sbu/javafx/MusicController.java | 60 +++++++++++---- src/main/java/sbu/javafx/Song.java | 26 +++++++ src/main/resources/sbu/javafx/App-view.fxml | 76 ++++++++++++++++++- 6 files changed, 154 insertions(+), 22 deletions(-) create mode 100644 .idea/vcs.xml create mode 100644 src/main/java/sbu/javafx/Song.java 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..89f05c9 100644 --- a/src/main/java/sbu/javafx/Launcher.java +++ b/src/main/java/sbu/javafx/Launcher.java @@ -2,7 +2,9 @@ package sbu.javafx; import javafx.application.Application; -public class Launcher{ +public class Launcher { public static void main(String[] args) { // TODO: Launch the JavaFX application by calling Application.launch(Main.class) } -} + + } +} \ No newline at end of file diff --git a/src/main/java/sbu/javafx/MusicController.java b/src/main/java/sbu/javafx/MusicController.java index 5da27a9..f3e9dd4 100644 --- a/src/main/java/sbu/javafx/MusicController.java +++ b/src/main/java/sbu/javafx/MusicController.java @@ -1,31 +1,59 @@ package sbu.javafx; import javafx.fxml.FXML; -import javafx.event.ActionEvent; import javafx.scene.control.Label; -import javafx.scene.input.MouseEvent; -import javafx.scene.layout.VBox; +import java.util.ArrayList; 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 ArrayList playlist = new ArrayList<>(); @FXML - public void handlePlayAction() { - //Update labels, change button icons, etc. + public void playSong1() { + nowPlayingLabel.setText("šŸŽµ Now Playing: Bohemian Rhapsody - Queen"); } - //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 playSong2() { + nowPlayingLabel.setText("šŸŽµ Now Playing: Imagine - John Lennon"); } - // TODO:This method should open a new window or change the current scene to display the "Playlist" page. - - public void openPlaylistWindow() { - //Create a new stage and show the playlist UI. + @FXML + public void playSong3() { + nowPlayingLabel.setText("šŸŽµ Now Playing: Billie Jean - Michael Jackson"); } -} + + @FXML + public void addToPlaylist1() { + playlist.add("Bohemian Rhapsody - Queen"); + System.out.println("āœ“ Added to playlist: Bohemian Rhapsody"); + } + + @FXML + public void addToPlaylist2() { + playlist.add("Imagine - John Lennon"); + System.out.println("āœ“ Added to playlist: Imagine"); + } + + @FXML + public void addToPlaylist3() { + playlist.add("Billie Jean - Michael Jackson"); + System.out.println("āœ“ Added to playlist: Billie Jean"); + } + + @FXML + public void viewPlaylist() { + System.out.println("\nšŸ“‹ ===== MY PLAYLIST ===== šŸ“‹"); + if (playlist.isEmpty()) { + System.out.println("Playlist is empty! Add some songs."); + } else { + for (int i = 0; i < playlist.size(); i++) { + System.out.println((i + 1) + ". " + playlist.get(i)); + } + } + System.out.println("==========================\n"); + } +} \ No newline at end of file diff --git a/src/main/java/sbu/javafx/Song.java b/src/main/java/sbu/javafx/Song.java new file mode 100644 index 0000000..239347f --- /dev/null +++ b/src/main/java/sbu/javafx/Song.java @@ -0,0 +1,26 @@ +package sbu.javafx; + +public class Song { + private String title; + private String artist; + private String duration; + + public Song(String title, String artist, String duration) { + this.title = title; + this.artist = artist; + this.duration = duration; + } + + public String getTitle() { return title; } + public String getArtist() { return artist; } + public String getDuration() { return duration; } + + public String getDisplayName() { + return title + " - " + artist + " (" + duration + ")"; + } + + @Override + public String toString() { + return getDisplayName(); + } +} diff --git a/src/main/resources/sbu/javafx/App-view.fxml b/src/main/resources/sbu/javafx/App-view.fxml index 306c8d3..8d076bd 100644 --- a/src/main/resources/sbu/javafx/App-view.fxml +++ b/src/main/resources/sbu/javafx/App-view.fxml @@ -1,8 +1,78 @@ + + + + + - - + - + + + + + + + +