From 58bc71aeb10679fbdef62dc1844f3bbc2bd9f22b Mon Sep 17 00:00:00 2001 From: Zahra Gharagozloo Mazlaghan Date: Tue, 2 Jun 2026 14:09:51 +0330 Subject: [PATCH] MusicController and MusicApp completed. --- src/main/java/sbu/javafx/Launcher.java | 2 +- src/main/java/sbu/javafx/MusicApp.java | 25 +++++++++++++++++++------ src/main/java/sbu/javafx/Song.java | 26 -------------------------- 3 files changed, 20 insertions(+), 33 deletions(-) delete mode 100644 src/main/java/sbu/javafx/Song.java diff --git a/src/main/java/sbu/javafx/Launcher.java b/src/main/java/sbu/javafx/Launcher.java index 89f05c9..49ae90e 100644 --- a/src/main/java/sbu/javafx/Launcher.java +++ b/src/main/java/sbu/javafx/Launcher.java @@ -5,6 +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..45027ad 100644 --- a/src/main/java/sbu/javafx/MusicApp.java +++ b/src/main/java/sbu/javafx/MusicApp.java @@ -3,21 +3,34 @@ package sbu.javafx; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; +import javafx.scene.image.Image; import javafx.stage.Stage; import java.io.IOException; +import java.util.Objects; public class MusicApp extends Application { @Override - public void start(Stage stage) throws IOException - { + public void start(Stage stage) throws IOException { FXMLLoader fxmlLoader = new FXMLLoader(MusicApp.class.getResource("App-view.fxml")); - Scene scene = new Scene(fxmlLoader.load()); - stage.setTitle("Music Player"); + Scene scene = new Scene(fxmlLoader.load(), 600, 550); + + stage.setTitle("🎵 Music Player"); + + try { + Image icon = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/icons/music_icon.png"))); + stage.getIcons().add(icon); + } catch (Exception e) { + System.out.println("Icon not found, continuing without icon."); + } + stage.setScene(scene); - //TODO: add icon to the stage + stage.setResizable(false); stage.show(); } -} + public static void main(String[] args) { + launch(args); + } +} \ No newline at end of file diff --git a/src/main/java/sbu/javafx/Song.java b/src/main/java/sbu/javafx/Song.java deleted file mode 100644 index 239347f..0000000 --- a/src/main/java/sbu/javafx/Song.java +++ /dev/null @@ -1,26 +0,0 @@ -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(); - } -}