This commit is contained in:
2026-07-17 02:17:25 +04:30
parent fa5f8ab267
commit f72a3e34a1
4 changed files with 71 additions and 22 deletions
Generated
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
+3 -1
View File
@@ -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) }
Application.launch(MusicApp.class, args);
}
}
+18 -5
View File
@@ -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);
}
}
+42 -14
View File
@@ -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<String> 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.
@FXML
public void playSong3() {
nowPlayingLabel.setText("🎵 Now Playing: Billie Jean - Michael Jackson");
}
public void openPlaylistWindow() {
//Create a new stage and show the playlist UI.
@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");
}
}