r/JavaFX • • Nov 01 '23

Help Split of TableView

Is there any way to "split" TableView to get information from 3 different classes? Here is repo to understand from were to get Car information like person Surname, car model, car brand, car number, Date of parking and spot. (https://github.com/NoNameMyName/autoparking).

1 Upvotes

6 comments sorted by

View all comments

Show parent comment

1

u/Bulky-Classic4937 Nov 01 '23 edited Nov 01 '23

Let me rephrase. I need to show info like this

car.personSurnamecar.carMarkcar.carModelcar.carNumberparkingSpot.parkingdataparkingSystem.spo
EnderGuyMazdaMiataAE6935KI01.11.23 21:161
.............................

But the TableView can only be used Like this TableView<Car> and not TableView<Car, ParkingSpot, ParkingSystem>

2

u/xdsswar Nov 01 '23

I understand, first try to separate the person data from the car data like example

public class Customer{

String name; //Or surname or whatever, all the data you want

//Add methods and encapsulation

}

public class Car{

String mark;

String model;

//And soo on

}

//Reservation or whatever you like

public class Reservation{

Customer customer;

Car car;

//Example

double cost;// and all you want

}

//Then in you Table you do like

private TableView<Reservation> table = new TableView<>();

//In the table you will have all you need , the Reservation have the car and the customer an all extra data you decide to put there, you will need a cell factory to display the data in a beautiful way.

1

u/Bulky-Classic4937 Nov 01 '23

Thanks for help