javafx projekt
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package sbu.javafx;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PlaylistController {
|
||||
|
||||
@FXML
|
||||
private VBox playlistContainer;
|
||||
|
||||
public void setPlaylist(ArrayList<String> playlist){
|
||||
playlistContainer.getChildren().clear();
|
||||
|
||||
if (playlist.isEmpty()){
|
||||
Label emptyLabel = new Label("Playlist is empty. Add some songs!");
|
||||
emptyLabel.setStyle("-fx-text-fill: #999; -fx-font-style: italic;");
|
||||
playlistContainer.getChildren().add(emptyLabel);
|
||||
}else {
|
||||
for (int i = 0; i < playlist.size(); i++) {
|
||||
Label songLabel = new Label((i+1) + ". " + playlist.get(i));
|
||||
songLabel.setStyle("-fx-padding: 5; -fx-font-size: 14px;");
|
||||
playlistContainer.getChildren().add(songLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void closePlaylistWindow(ActionEvent actionEvent) {
|
||||
Stage stage = (Stage) playlistContainer.getScene().getWindow();
|
||||
stage.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user