0

I can't seem to get data to show up in a row. This returns an order table which is implemented successfully. The table appears, and if I use literals instead of variables the data shows correctly (ie, instead of orderRows[0] if I put "Boo" it works). I feel like I have something right under my nose that I can't see. As a note, I have confirmed my OrderData class is successfully passing the appropriate string to OrderRows. My row header is showing up properly "Ship Date". The row below is blank. What am I forgetting?

public class viewOrderTable {
  //This is where my orderData is created.
  //I have verified this is putting a correct value in OrderRows.
  static OrderData orderData = new OrderData();
  static OrderRows[] orderRows = orderData.GetOrderRows();
  private final static ObservableList<OrderRows> rowMaker =
  FXCollections.observableArrayList(orderRows[0]);

  public static TableView<OrderRows> viewOrderTableBuilder() {
    TableView<OrderRows> addOrderTable = new TableView();
    TableColumn<OrderRows,String> shipDate = new 
    TableColumn<OrderRows,String> ("Ship Date");
    shipDate.setCellValueFactory(new PropertyValueFactory("shipDate"));
    addOrderTable.setItems(rowMaker);
    addOrderTable.getColumns().addAll(shipDate);
    return addOrderTable;
    }

This is my OrderRows class:

public class OrderRows {
    private String shipDate;


    public OrderRows(String shipDate,) {
        this.shipDate = shipDate;

    }
    public String getshipDate() {
        return shipDate;
    }

}
  • Your getMethod change it to `getShipDate` and check it. – Dakshinamurthy Karra Nov 13 '18 at 06:12
  • When `orderData.GetOrderRows()` runs it probably returns an empty array. Then `private final static ObservableList rowMaker = FXCollections.observableArrayList(orderRows[0]);` creates an observable list containing the first element, which throws an index out of bounds exception. The elements are likely loaded after that. In short, the order of execution messed up your application. – Jai Nov 13 '18 at 06:32

0 Answers0