The table should display the name of the Airline, Origin and Destination, Time of Departure and Arrival of a certain flight.
but with the code I have, the only items that show are the origin and destination.
I have a constructor for flight at the start of my code which is:
Flight tableflight = new Flight("PAL","PHP","ZBW", 2016, 8, 16, 23, 30, 2016, 8, 16, 23, 50, 25000.0, 6669.0);
inside the flight class, the inputted ints in the constructor are turned into GregorianCalenday Objects.
public static void flightOps(ObservableList<Flight>obsFlight){
TableView<Flight> table;
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm");
Label deps = new Label("Departure Date");
Label arrs = new Label("Arrival Date");
Label yearLab = new Label("Year:");
Label monthLab = new Label("Month:");
Label dayLab = new Label("Day:");
Label hourLab = new Label("Hour:");
Label minuteLab = new Label("Minute:");
Stage lineWindow = new Stage();
lineWindow.initModality(Modality.APPLICATION_MODAL);
lineWindow.setTitle("Harambe's Aircraft Options");
//Name column
TableColumn<Flight, String> nameColumn = new TableColumn<>("Airline");
nameColumn.setMinWidth(100);
nameColumn.setCellValueFactory(new PropertyValueFactory<>("airlineName"));
//Origin column
TableColumn<Flight, String> orgColumn = new TableColumn<>("Origin");
orgColumn.setMinWidth(50);
orgColumn.setCellValueFactory(new PropertyValueFactory<>("origin"));
//Destination column
TableColumn<Flight, String> desColumn = new TableColumn<>("Destination");
desColumn.setMinWidth(50);
desColumn.setCellValueFactory(new PropertyValueFactory<>("destination"));
//departure time column
TableColumn<Flight, GregorianCalendar>depColumn = new TableColumn<>("Departure Times");
depColumn.setMinWidth(150);
depColumn.setCellValueFactory(new PropertyValueFactory<>("dep"));
//arrival time column
TableColumn<Flight, GregorianCalendar>arrColumn = new TableColumn<>("Arrival Times");
arrColumn.setMinWidth(150);
arrColumn.setCellValueFactory(new PropertyValueFactory<>("arr"));
table = new TableView<>();
table.setItems(obsFlight);
table.getColumns().addAll(nameColumn, orgColumn, desColumn, depColumn, arrColumn);
VBox vBox = new VBox();
vBox.getChildren().addAll(table);
Scene scene = new Scene(vBox);
lineWindow.setScene(scene);
scene.getStylesheets().add("default.css");
lineWindow.showAndWait();
}
//Flight class
import java.util.ArrayList;
import java.util.GregorianCalendar;
public class Flight
{
protected String airlineName;
protected String origin;
protected String destination;
protected int depYear, depMonth, depDay, depHour, depMinute, arrYear, arrMonth, arrDay, arrHour, arrMinute;
protected String aircraftType;
protected double cost, miles;
protected GregorianCalendar dep, arr;
private ArrayList<GregorianCalendar> departures = new ArrayList<GregorianCalendar>();
private ArrayList<GregorianCalendar> arrivals = new ArrayList<GregorianCalendar>();
public Flight(String airlineName, String origin, String destination, int depYear, int depMonth, int depDay,
int depHour, int depMinute, int arrYear, int arrMonth, int arrDay, int arrHour, int arrMinute,
double cost, double miles, String aircraftType) {
this.airlineName = getAirlineName();
this.origin = origin;
this.destination = destination;
this.depYear = depYear;
this.depMonth = depMonth;
this.depDay = depDay;
this.depHour = depHour;
this.depMinute = depMinute;
this.arrYear = arrYear;
this.arrMonth = arrMonth;
this.arrDay = arrDay;
this.arrHour = arrHour;
this.arrMinute = arrMinute;
this.cost = cost; this.miles = miles;
this.dep = new GregorianCalendar(depYear, depMonth, depDay, depHour, depMinute);
this.arr = new GregorianCalendar(arrYear, arrMonth, arrDay, arrHour, arrMinute);
this.aircraftType = aircraftType;
departures = new ArrayList<GregorianCalendar>();
arrivals = new ArrayList<GregorianCalendar>();
}
public double getCost() {
return cost;
}
public void setCost(double cost) {
this.cost = cost;
}
public double getMiles() {
return miles;
}
public void setMiles(double miles) {
this.miles = miles;
}
public int getDepHour() {
return depHour;
}
public void setDepHour(int depHour) {
this.depHour = depHour;
}
public int getDepMinute() {
return depMinute;
}
public void setDepMinute(int depMinute) {
this.depMinute = depMinute;
}
public int getArrHour() {
return arrHour;
}
public void setArrHour(int arrHour) {
this.arrHour = arrHour;
}
public int getArrMinute() {
return arrMinute;
}
public void setArrMinute(int arrMinute) {
this.arrMinute = arrMinute;
}
Flight() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
/**
* @return the airlineCode
*/
public String getAirlineName() {
return airlineName;
}
/**
* @param airlineName the airlineCode to set
*/
public void setAirlineName(String airlineName) {
this.airlineName = airlineName;
}
/**
* @return the origin
*/
public String getOrigin() {
return origin;
}
/**
* @param origin the origin to set
*/
public void setOrigin(String origin) {
this.origin = origin;
}
/**
* @return the destination
*/
public String getDestination() {
return destination;
}
/**
* @param destination the destination to set
*/
public void setDestination(String destination) {
this.destination = destination;
}
public int getDepYear() {
return depYear;
}
public void setDepYear(int depYear) {
this.depYear = depYear;
}
public int getDepMonth() {
return depMonth;
}
public void setDepMonth(int depMonth) {
this.depMonth = depMonth;
}
public int getDepDay() {
return depDay;
}
public void setDepDay(int depDay) {
this.depDay = depDay;
}
public int getArrYear() {
return arrYear;
}
public void setArrYear(int arrYear) {
this.arrYear = arrYear;
}
public int getArrMonth() {
return arrMonth;
}
public void setArrMonth(int arrMonth) {
this.arrMonth = arrMonth;
}
public int getArrDay() {
return arrDay;
}
public void setArrDay(int arrDay) {
this.arrDay = arrDay;
}
/**
* @return the aircraftType
*/
public String getAircraftType() {
return aircraftType;
}
/**
* @param aircraftType the aircraftType to set
*/
public void setAircraftType(String aircraftType) {
this.aircraftType = aircraftType;
}
public void setDepartures(GregorianCalendar g){
departures.add(g);
}
public void setArrivals(GregorianCalendar g){
arrivals.add(g);
}
}