0

I have a simple 5 column table

public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
    ...

    filename.setCellValueFactory( new PropertyValueFactory<Filedata,String>("filename") );
    path.setCellValueFactory( new PropertyValueFactory<Filedata,String>("path") );
    size.setCellValueFactory( new PropertyValueFactory<Filedata,String>("size") );
    md5.setCellValueFactory( new PropertyValueFactory<Filedata,String>("md5") );
    sha256.setCellValueFactory( new PropertyValueFactory<Filedata,String>("sha256") );

    table.setItems(eeModel.data);       
}   

which I populate with some 220,000 records.

I'm finding that resizing the column width (by double-clicking the column divider) takes a very long time, some 10 seconds or so. Is that expected or is there something I can do to speed it up?

Monitoring with Process Explorer I see the following whilst resizing 3 columns. As this is a quad core machine its looking like the UI thread is 100% busy during those periods.

http://i57.tinypic.com/ienl3a.jpg

Ian
  • 1,507
  • 3
  • 21
  • 36
  • If you really want a table with that many rows, then there's probably not much you can do to speed this up. To "autosize" the column width, the table has to create a cell for every item in the column, apply css to it, measure it, and (for almost every cell) discard the cell. I guess I'd question whether you really want that many rows in the table: perhaps use pagination to break it up and/or implement some user-based filtering. Your users aren't going to look at all 220K rows, after all... – James_D Sep 01 '14 at 23:10
  • Thanks James_D. I suspected that was what it was doing. It's got 220k (or more...) rows in its /unfiltered/ state, for sure no one's going to be paging through all that. But if they /do/ hit "autosize" on it then the UI goes to sleep for that 10 seconds which is yucky. I was hoping that, if there's no way to speed it up I maybe could override the resize operation in some way to either just examine those rows actually displayed, or for me to give it the longest string (at least mono-spaced) without it having to search for it. Any way of doing those per chance? – Ian Sep 01 '14 at 23:37
  • I remember it only resizing for the next 30 rows. Check this question. http://stackoverflow.com/q/23656387/2855515 . Maybe you have to implement yourself, but that 30 in my answer is the number of rows. – brian Sep 02 '14 at 00:15
  • I *think* it resizes for 30 rows only when first displayed, but resizes for all rows when you double-click the divider. I dug into the source code a little, and I am certain about the first part, but didn't dig deep enough to find where it's invoked for the double click. The `resizeColumnToFitContent` method in [`TableViewSkin`](http://hg.openjdk.java.net/openjfx/8/master/rt/file/f89b7dc932af/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TableViewSkin.java) is designed to be called to resize all rows (by passing maxRows=-1). I'd have to dig further to be sure though. – James_D Sep 02 '14 at 00:51

0 Answers0