1 Reply Latest reply: Nov 7, 2012 12:53 PM by James_D RSS

    how to set cells size in listview?

    user13335782
      Hi,

      How to set size of cells in ListView?

      I've got listView with borderPane inside:
      ListView<BorderPane> presetList = new ListView<BorderPane>();
      and I want to set height of cell to let's say 8pt...

      Thanks in advance.
        • 1. Re: how to set cells size in listview?
          James_D
          You almost certainly don't want to do it like this. The type of the ListView, BorderPane in your example, is the type of the data to be displayed in each cell. It's not the type of the node that is used to display each cell. It is almost always a mistake to use a graphical node as the data type for a control.

          To change the display type for each cell in the ListView, use the setCellFactory(...) method and pass in a Callback that creates a custom ListCell in its call method. The ListCell will use the BorderPane as its graphic. You can then set the height of the BorderPane as needed.

          Example 12.4 in http://docs.oracle.com/javafx/2/ui_controls/list-view.htm is an example of using a custom list cell.