Fit text in Javafx tableview

0

I am filling in a table with data, but there is a column called observations in which the text is often very long and leaves the cell. I would like to know in what way I can make the cell expand downwards and show the full text, as in excel the text is used.

something like this code:

Render code

I tried to implement but I get an error in the initialize:

col_obserrvaciones.setCellFactory (WRAPPING_CELL_FACTORY);

I do not take the setCellFactory, I'm wrong with it.

    
asked by Yolfran Montaño Corredor 28.10.2018 в 07:05
source

1 answer

0

A simpler way to do this is to use CSS with the table to format the text

.table-view .cell{ // modificas de la tabla los parámetros de cada celda
-fx-wrap-text: true;  /*estableces que el texto dentro del label de la celda pueda ser divido en partes*/
-fx-cell-size: 60px ;/* fijas la altura de la celda. Prueba con varios valores para que veas el efecto*/
-fx-pref-width: 40px; /* Estableces el ancho del label dentro de la celda.*/

 }
    
answered by 26.11.2018 в 02:20