TableView not adding all the information into a table

时间:2015-12-10 01:47:22

标签: java user-interface javafx tableview

So we have a tableview in our Javafx GUI and we are trying to add certain information into the columns, but for some reason it is only adding information into two of the columns.

      ObservableList<MediaViewModel> mediaData = FXCollections.observableArrayList();

public void initialize()
{
    ObservableList<String> formatList = FXCollections.observableArrayList("DVD", "Blu-Ray", "Game", "Music");
    formatBox.getItems().addAll(formatList);
    formatBox.setItems(formatList);
    ObservableList<String> locationList = FXCollections.observableArrayList("Home", "iTunes", "Amazon", "Microsoft");
    locationBox.getItems().addAll(locationList);
    locationBox.setItems(locationList);
    ObservableList<Boolean> rippedList = FXCollections.observableArrayList(true, false);
    rippedBox.getItems().addAll(rippedList);
    rippedBox.setItems(rippedList);
    ObservableList<String> filterList = FXCollections.observableArrayList("DVD", "Blu-Ray", "Game", "Music");
    filterBox.getItems().addAll(filterList);
    filterBox.setItems(filterList);
    titleColumn.setCellValueFactory(new PropertyValueFactory<MediaViewModel, String>("title"));
    formatColumn.setCellValueFactory(new PropertyValueFactory<MediaViewModel, String>("format"));
    locationColumn.setCellValueFactory(new PropertyValueFactory<MediaViewModel, String>("location"));
    rippedColumn.setCellValueFactory(new PropertyValueFactory<MediaViewModel, String>("ripped"));
    releaseDateColumn.setCellValueFactory(new PropertyValueFactory<MediaViewModel, String>("releaseDate"));
    purchaseDateColumn.setCellValueFactory(new PropertyValueFactory<MediaViewModel, String>("purchaseDate"));
    ownerColumn.setCellValueFactory(new PropertyValueFactory<MediaViewModel, String>("owner"));
    mediaData.add(new MediaViewModel("Hello","02-4-2001", "04-31-2005","true","DVD","Me","Home"));
    mediaTable.setItems(mediaData);


}

and here is our mediaviewmodel class

    public class MediaViewModel //extends Application 
    {
    private final SimpleStringProperty title;
    private final SimpleStringProperty releaseDate;
    private final SimpleStringProperty purchaseDate;
    private final SimpleStringProperty format;
    private final SimpleStringProperty ripped;
    private final SimpleStringProperty location;
    private final SimpleStringProperty owner;
    //private final SimpleStringProperty ownerFN;
    //private final SimpleStringProperty ownerLN;
    //private final SimpleStringProperty ownerPhone;

    public MediaViewModel(String t, String rDate, String pDate, String r, String f, String o, String l) 
    {
        this.title = new SimpleStringProperty(t);
        this.releaseDate = new SimpleStringProperty(rDate);         
        this.purchaseDate = new SimpleStringProperty(pDate);
        this.format = new SimpleStringProperty(f);
        this.ripped = new SimpleStringProperty(r);
        this.location = new SimpleStringProperty(l);
        this.owner = new SimpleStringProperty(o);
    }

    public String getTitle() 
    {
        return title.get();
    }
    public void setTitle(String t) 
    {
        title.set(t);
    }

    public String getReleaseDate() 
    {
        return releaseDate.get();
    }
    public void setreleaseDate(String rDate) 
    {
        releaseDate.set(rDate);
    }

    public String getpurchaseDate()
    {
        return purchaseDate.get();
    } 
    public void setpurchaseDate(String pDate)
    {
        purchaseDate.set(pDate);
    }

    public String getformat()
    {
        return format.get();
    }
    public void setformat(String f)
    {
        format.set(f);
    }

    public String getripped()
    {
        return ripped.get();
    }
    public void setripped(String r)
    {
        ripped.set(r);  
    }

    public String getlocation()
    {
        return location.get();
    }
    public void setlocation(String l)
    {
        location.set(l);
    }

    public String getowner()
    {
        return owner.get();
    }
    public void setowner(String o)
    {
        owner.set(o);
    }

The only columns being initialized are the title column and the release date column on the mediatable tableview object.

0 个答案:

没有答案