Develop #1

Merged
HoseinA05 merged 4 commits from develop into main 2026-07-30 11:12:25 +00:00
2 changed files with 76 additions and 22 deletions
Showing only changes of commit 58536d2bce - Show all commits
+54 -10
View File
@@ -1,31 +1,75 @@
package sbu.javafx; package sbu.javafx;
import javafx.fxml.FXML; import javafx.collections.FXCollections;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent; import javafx.scene.control.ListView;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import java.util.ArrayList;
public class MusicController { 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 ArrayList<String> playlist = new ArrayList<>();
@FXML @FXML
public void handlePlayAction() { public void handlePlayAction(ActionEvent event) {
//Update labels, change button icons, etc. Button button = (Button) event.getSource();
String songName = "";
switch (button.getId()) {
case "play1":
songName = "Blinding Lights";
break;
case "play2":
songName = "Shape of You";
break;
case "play3":
songName = "Believer";
break;
} }
//TODO: Logic to add a specific song to the user's playlist. nowPlayingLabel.setText("Now Playing: " + songName);
}
public void addToPlaylist(String songName) { 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 addSong1() {
addToPlaylist("Blinding Lights");
}
@FXML
public void addSong2() {
addToPlaylist("Shape of You");
}
@FXML
public void addSong3() {
addToPlaylist("Believer");
}
@FXML
public void openPlaylistWindow() { public void openPlaylistWindow() {
//Create a new stage and show the playlist UI.
Stage stage = new Stage();
ListView<String> listView = new ListView<>();
listView.setItems(FXCollections.observableArrayList(playlist));
VBox root = new VBox(10);
root.getChildren().addAll(new Label("Playlist"), listView);
stage.setScene(new Scene(root, 300, 250));
stage.setTitle("Playlist");
stage.show();
} }
} }
+20 -10
View File
@@ -12,28 +12,38 @@
spacing="10"> spacing="10">
<Label fx:id="nowPlayingLabel" text="Now Playing: None"/> <Label fx:id="nowPlayingLabel" text="Now Playing: None"/>
<HBox spacing="10" alignment="CENTER"> <HBox alignment="CENTER" spacing="10">
<Label text="Blinding Lights"/> <Label text="Blinding Lights"/>
<Label text="The Weeknd"/> <Label text="The Weeknd"/>
<Label text="3:20"/> <Label text="3:20"/>
<Button text="Play" onAction="#handlePlayAction"/> <Button fx:id="play1"
<Button text="Add to Playlist"/> text="Play"
onAction="#handlePlayAction"/>
<Button text="Add to Playlist"
onAction="#addSong1"/>
</HBox> </HBox>
<HBox spacing="10" alignment="CENTER"> <HBox alignment="CENTER" spacing="10">
<Label text="Shape of You"/> <Label text="Shape of You"/>
<Label text="Ed Sheeran"/> <Label text="Ed Sheeran"/>
<Label text="4:02"/> <Label text="4:02"/>
<Button text="Play" onAction="#handlePlayAction"/> <Button fx:id="play2"
<Button text="Add to Playlist"/> text="Play"
onAction="#handlePlayAction"/>
<Button text="Add to Playlist"
onAction="#addSong2"/>
</HBox> </HBox>
<HBox spacing="10" alignment="CENTER"> <HBox alignment="CENTER" spacing="10">
<Label text="Believer"/> <Label text="Believer"/>
<Label text="Imagine Dragons"/> <Label text="Imagine Dragons"/>
<Label text="3:24"/> <Label text="3:24"/>
<Button text="Play" onAction="#handlePlayAction"/> <Button fx:id="play3"
<Button text="Add to Playlist"/> text="Play"
onAction="#handlePlayAction"/>
<Button text="Add to Playlist"
onAction="#addSong3"/>
</HBox> </HBox>
<Button text="View Playlist" onAction="#openPlaylistWindow"/> <Button text="View Playlist"
onAction="#openPlaylistWindow"/>
</VBox> </VBox>