Merge pull request 'complete' (#1) from develop into main

This commit was merged in pull request #1.
This commit is contained in:
2026-07-03 07:15:07 +00:00
7 changed files with 212 additions and 17 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>
+2 -1
View File
@@ -4,5 +4,6 @@ import javafx.application.Application;
public class Launcher{ public class Launcher{
public static void main(String[] args) { public static void main(String[] args) {
// TODO: Launch the JavaFX application by calling Application.launch(Main.class) } Application.launch(MusicApp.class, args);
}
} }
+2 -1
View File
@@ -4,6 +4,7 @@ import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.scene.image.Image;
import java.io.IOException; import java.io.IOException;
@@ -16,7 +17,7 @@ public class MusicApp extends Application {
Scene scene = new Scene(fxmlLoader.load()); Scene scene = new Scene(fxmlLoader.load());
stage.setTitle("Music Player"); stage.setTitle("Music Player");
stage.setScene(scene); stage.setScene(scene);
//TODO: add icon to the stage scene.getStylesheets().add(getClass().getResource("dark.css").toExternalForm());
stage.show(); stage.show();
} }
+65 -12
View File
@@ -3,29 +3,82 @@ package sbu.javafx;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
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.
@FXML @FXML
public void handlePlayAction() { private Button playBtn1, playBtn2, playBtn3;
//Update labels, change button icons, etc. private final ArrayList<String> playlist = new ArrayList<>();
private boolean isDark = true;
@FXML
public void toggleTheme() {
Scene scene = playBtn1.getScene();
scene.getStylesheets().clear();
if (isDark) {
scene.getStylesheets().add(getClass().getResource("light.css").toExternalForm());
} else {
scene.getStylesheets().add(getClass().getResource("dark.css").toExternalForm());
}
isDark = !isDark;
} }
private void resetPlayButtons() {
playBtn1.setText("Play");
playBtn1.setStyle(null);
playBtn2.setText("Play");
playBtn2.setStyle(null);
playBtn3.setText("Play");
playBtn3.setStyle(null);
}
@FXML
public void handlePlayAction(ActionEvent event) {
resetPlayButtons();
Button clicked = (Button) event.getSource();
clicked.setText("Playing");
clicked.setStyle("-fx-background-color: #4CAF50; -fx-text-fill: white;");
//TODO: Logic to add a specific song to the user's playlist. if (clicked == playBtn1) {
nowPlayingLabel.setText("Now Playing: Blinding Lights - The Weeknd");
} else if (clicked == playBtn2) {
nowPlayingLabel.setText("Now Playing: Bohemian Rhapsody - Queen");
} else if (clicked == playBtn3) {
nowPlayingLabel.setText("Now Playing: Hotel California - Eagles");
}
}
public void addToPlaylist(String songName) { public void addToPlaylist(String songName) {
//Add the song to a list or update a ListView. playlist.add(songName);
System.out.println("Added to playlist: " + songName);
} }
@FXML
// TODO:This method should open a new window or change the current scene to display the "Playlist" page.
public void openPlaylistWindow() { public void openPlaylistWindow() {
//Create a new stage and show the playlist UI. Stage playlistStage = new Stage();
playlistStage.setTitle("My Playlist");
ListView<String> listView = new ListView<>();
listView.getItems().addAll(playlist);
VBox root = new VBox(listView);
Scene scene = new Scene(root, 300, 400);
playlistStage.setScene(scene);
playlistStage.show();
} }
@FXML
public void handleAdd1() { addToPlaylist("Blinding Lights - The Weeknd"); }
@FXML
public void handleAdd2() { addToPlaylist("Bohemian Rhapsody - Queen"); }
@FXML
public void handleAdd3() { addToPlaylist("Hotel California - Eagles"); }
} }
+39 -3
View File
@@ -1,8 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<VBox xmlns="http://javafx.com/fxml" alignment="CENTER" spacing="10">
<!-- TODO: Add your code here! -->
<VBox xmlns="http://javafx.com/fxml"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="sbu.javafx.MusicController"
alignment="CENTER" spacing="15">
<padding><Insets top="25" right="25" bottom="25" left="25"/></padding>
<HBox spacing="20" alignment="CENTER">
<Label text="🎵 Music Player" styleClass="header-title"/>
<Button text="Toggle Theme" onAction="#toggleTheme"/>
</HBox>
<Label fx:id="nowPlayingLabel" text="Now Playing: None" styleClass="now-playing"/>
<VBox styleClass="song-card" spacing="8">
<Label text="Blinding Lights" styleClass="song-title"/>
<Label text="The Weeknd · 3:20" styleClass="song-artist"/>
<HBox spacing="10">
<Button fx:id="playBtn1" text="Play" onAction="#handlePlayAction" styleClass="play-btn"/>
<Button text="+ Playlist" onAction="#handleAdd1" styleClass="add-btn"/>
</HBox>
</VBox>
<VBox styleClass="song-card" spacing="8">
<Label text="Bohemian Rhapsody" styleClass="song-title"/>
<Label text="Queen · 5:55" styleClass="song-artist"/>
<HBox spacing="10">
<Button fx:id="playBtn2" text="Play" onAction="#handlePlayAction" styleClass="play-btn"/>
<Button text="+ Playlist" onAction="#handleAdd2" styleClass="add-btn"/>
</HBox>
</VBox>
<VBox styleClass="song-card" spacing="8">
<Label text="Hotel California" styleClass="song-title"/>
<Label text="Eagles · 6:30" styleClass="song-artist"/>
<HBox spacing="10">
<Button fx:id="playBtn3" text="Play" onAction="#handlePlayAction" styleClass="play-btn"/>
<Button text="+ Playlist" onAction="#handleAdd3" styleClass="add-btn"/>
</HBox>
</VBox>
<Button text="View Playlist" onAction="#openPlaylistWindow" styleClass="view-playlist-btn"/>
</VBox> </VBox>
+51
View File
@@ -0,0 +1,51 @@
.root {
-fx-background-color: #1a1a2e;
-fx-font-family: "Segoe UI", sans-serif;
}
.header-title {
-fx-font-size: 24px;
-fx-font-weight: bold;
-fx-text-fill: #ffffff;
}
.now-playing {
-fx-font-size: 14px;
-fx-text-fill: #aaaaaa;
}
.song-card {
-fx-background-color: #2d2d44;
-fx-padding: 15;
-fx-background-radius: 10;
-fx-effect: dropshadow(gaussian, rgba(0,0,0,0.3), 5, 0, 0, 2);
}
.song-title {
-fx-font-size: 16px;
-fx-font-weight: bold;
-fx-text-fill: #ffffff;
}
.song-artist {
-fx-text-fill: #888888;
}
.play-btn {
-fx-background-color: #2196F3;
-fx-text-fill: white;
}
.play-btn:disabled {
-fx-opacity: 0.6;
}
.add-btn {
-fx-background-color: #4a4a6a;
-fx-text-fill: white;
}
.view-playlist-btn {
-fx-background-color: #9C27B0;
-fx-text-fill: white;
}
+47
View File
@@ -0,0 +1,47 @@
.root {
-fx-background-color: #f5f5f5;
-fx-font-family: "Segoe UI", sans-serif;
}
.header-title {
-fx-font-size: 24px;
-fx-font-weight: bold;
-fx-text-fill: #1a1a2e;
}
.now-playing {
-fx-font-size: 14px;
-fx-text-fill: #555555;
}
.song-card {
-fx-background-color: #ffffff;
-fx-padding: 15;
-fx-background-radius: 10;
-fx-effect: dropshadow(gaussian, rgba(0,0,0,0.1), 5, 0, 0, 2);
}
.song-title {
-fx-font-size: 16px;
-fx-font-weight: bold;
-fx-text-fill: #000000;
}
.song-artist {
-fx-text-fill: #888888;
}
.play-btn {
-fx-background-color: #2196F3;
-fx-text-fill: white;
}
.add-btn {
-fx-background-color: #e0e0e0;
-fx-text-fill: #1a1a2e;
}
.view-playlist-btn {
-fx-background-color: #9C27B0;
-fx-text-fill: white;
}