Search code examples
javajavafxfxmlborderpane

How to make node of borderpane fixed?


As stated at javafx docs for borderpane here,

If the window is smaller than the space needed for the contents of each region, the regions might overlap. The overlap is determined by the order in which the regions are set. For example, if the regions are set in the order of left, bottom, and right, when the window is made smaller, the bottom region overlaps the left region and the right region overlaps the bottom region.

I have top and bottom panes, that are pre-defined from fxml and a center pane that consists of ImageView that is updated programmatically. I need top and bottom panes to be always shown. However, when I resize application window, the top pane disappears. As far as I understand, that is because center pane was updated last (according to docs). How to set this element to be fixed? I tried to set minHeight="100.00" at my fxml file, but this doesn't work.


Solution

  • Make sure you define the top and bottom regions after the center in the FXML file:

    <BorderPane>
      <center><!-- ... --></center>
      <top><!-- ... --></top>
      <bottom><!-- ... --></bottom>
    </BorderPane>