Wednesday 9 April 2014

FX 2.2 to FX 8.0 Part 6 (scrollpane)

I have a view in which data from previous appointments are displayed side by side in a grid. The entire view is comprised of a number of GridPanes, one of which forms a header grid at the top (think table column header). This GridPane is inside a ScrollPane synchronized with the main data grid's own ScrollPane, below it. In FX 2.2 a section of the header and main grid looks like so:


If you look carefully at the top right hand scroll bar you'll notice that the bottom arrow is missing. The top scroll pane is actually bigger than what is shown but its tucked away behind something. This didn't bother me in FX 2.2, to be honest I think I only noticed it now while doing this blog !  However in FX 8.0 this is no longer the case and it initially looked like so:


See how the bottom arrow of the top scroll bar is now visible but now there's a gap between the top header grid and the main grid under it. Well I didn't like it, the gap had to go !  I used ScenicView (thanks for this tool) to discover that the gap was coming from the scroll pane and not the grid pane. So I figured it must have a minimum or preferred height that is preventing it from being smaller. The answer was:  headerScroll.setMinHeight( 0 )  with the following result:


Unfortunately that isn't the end of my scroll pains. The main or center grid's scroll pane position is bound to a left hand row label grid scroll pane as well as the header pane above it: 
centerScroll.hvalueProperty().bindBidirectional( headerScroll.hvalueProperty() );
centerScroll.vvalueProperty().bindBidirectional( leftScroll.vvalueProperty() );
So if you pan or scroll around in the center pane its supposed to keep the row labels and column headers in sync. Well this works great in FX 2.2 but for some strange reason it sometimes becomes unhinged in FX 8.0 (especially when panning) and then the columns and rows aren't synchronized anymore, like so:



This is related to RT-35783 and is apparently fixed for FX 8u20 :-) 

The GridPane however was also "misbehaving" in this case .... see part 7.

No comments:

Post a Comment