Hi guys I am new to java and I am stuck.
I have created a class called song with the code below
package musiclibrary;
public class Song {
private String title;
private String albumArtist;
private String genre;
private double price;
private int duration;
public Song() {
}
public Song(String title, String albumArtist, String genre, double price, int duration) {
this.title = title;
this.albumArtist = albumArtist;
this.genre = genre;
this.price = price;
this.duration = duration;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAlbumArtist() {
return albumArtist;
}
public void setAlbumArtist(String albumArtist) {
this.albumArtist = albumArtist;
}
public String getGenre() {
return genre;
}
public void setGenre(String genre) {
this.genre = genre;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getDuration() {
return duration;
}
public void setDuration(int durationSeconds) {
this.duration = durationSeconds;
}
}
and i have created an object array as shown below
private ObservableList<Song> songs =FXCollections.observableArrayList();
public ObservableList<Song> load()
{
songs.add(new Song("J. Cole", "Lost Ones", "Hip Hop", 24.66, 3000));
songs.add(new Song("Erykah Badu", "Time's a wasting", "Neo-Soul", 24.66, 4000));
songs.add(new Song("Common", "Book of Life", "Hip Hop", 24.66, 2000));
songs.add(new Song("CommonGround", "dasdsad", "asdsadsad", 24.66, 3000));
return songs;
}
Problem is that I don't know how to call the "load" function in a listView in the main method. below is what i have
private ListView<Song> ListView;
@Override
public void initialize(URL url, ResourceBundle rb) {
PlayList pl= new PlayList();
ListView.setItems(pl.play());
}
Attached is the result. please help!