Load Object Data into a TableView in IntelliJ using JavaFX

Tiempo de lectura: 2 minutos

Reading time: 3 minutes

We begin by creating the design of the application window, where we need to add a TableView element. We give this element its own ID, in this case, I’ll call it “tablaAplicaciones”, resulting in the window looking like this:



Next, in order to display the data in the table, we are going to create a Model object with fields corresponding to the table columns.

In this case, the object will be named “objetoModel”. The types to be declared for its attributes within the class are IntegerProperty for numbers and StringProperty for text or strings.

Then, we create a constructor for the object, passing it as either String or Integer, and convert the object into SimpleIntegerProperty (for integers) or SimpleStringProperty (for strings) based on the type of data it will receive.

We also add getter and setter methods using the lombok annotation “@Data” to reduce code.

Here is an example:


Now, within the class that references the view, we associate the TableView element and declare it along with the table columns as shown below.

To populate the table, we simply instantiate multiple objects of the previously created class (ObjetoModel) with the data we want to display in the table. We also create an ObservableList:


Finally, we transfer the data from the “listaApps” list to the “objetoModelObservableList” and assign the data from the “objetoModelObservableList” to the columns using their corresponding getters:


Once the data is collected, it will be displayed in the TableView when the application is executed or launched.

We verify the result by following the previous steps:


I hope this helps, regards!

Leave a Comment