Develop #1
Generated
+1
-1
@@ -8,7 +8,7 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="23" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" default="true" project-jdk-name="25" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -17,12 +17,26 @@
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>17.0.6</version>
|
||||
<version>21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
<version>17.0.6</version>
|
||||
<version>21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-media</artifactId>
|
||||
<version>21</version>
|
||||
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>de.codecentric.centerdevice</groupId>
|
||||
<artifactId>javafxsvg</artifactId>
|
||||
<version>1.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package sbu.javafx;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlaylistController {
|
||||
|
||||
@FXML
|
||||
private VBox songContainer;
|
||||
|
||||
private ArrayList<Song> playlist;
|
||||
private MusicController musicController;
|
||||
|
||||
public void setPlaylist(List<Song> playlist, MusicController musicController)
|
||||
{
|
||||
this.playlist = new ArrayList<> (playlist);
|
||||
this.musicController = musicController;
|
||||
buildRows();
|
||||
}
|
||||
|
||||
public void buildRows()
|
||||
{
|
||||
songContainer.getChildren().clear();
|
||||
|
||||
for (Song s : playlist)
|
||||
{
|
||||
HBox hbox = new HBox(20); //spacing = 20
|
||||
hbox.setAlignment(javafx.geometry.Pos.CENTER);
|
||||
Label nameLabel = new Label(s.getDisplayName());
|
||||
nameLabel.setPrefWidth(250);
|
||||
|
||||
Label durationLabel = new Label(s.getDuration());
|
||||
|
||||
Button playBtn = new Button("Play");
|
||||
playBtn.setPrefWidth(80);
|
||||
|
||||
playBtn.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent actionEvent) {
|
||||
if (musicController != null) {
|
||||
musicController.playSong(s);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
hbox.getChildren().addAll(nameLabel, durationLabel, playBtn);
|
||||
songContainer.getChildren().add(hbox);
|
||||
}
|
||||
|
||||
if (playlist.isEmpty()) {
|
||||
Label emptyLabel = new Label("Playlist is empty. Add some songs from the main page.");
|
||||
emptyLabel.setStyle("-fx-text-fill: gray;");
|
||||
songContainer.getChildren().add(emptyLabel);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<VBox xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="sbu.javafx.PlaylistController"
|
||||
spacing="10" alignment="CENTER" style="-fx-padding: 20;">
|
||||
<Label text="Your Playlist" style="-fx-font-size: 30px; -fx-font-weight: bold;"/>
|
||||
<VBox fx:id="songContainer" spacing="5" alignment="CENTER"/>
|
||||
</VBox>
|
||||
|
||||
<!--future feature: remove from playlist-->
|
||||
Reference in New Issue
Block a user