Controlling node location with AnchorPane

AnchorPane is a powerful tool for fine-tuning the resize process. It allows us to precisely attach nodes to the four sides of the window.

Imagine we are creating a browser that consists of the following components:

  • An address bar
  • Navigation buttons
  • A status bar
  • A web view:

If the browser is being resized, we want the following adaptive behavior:

  • The address bar stays on top and changes size only in the horizontal direction
  • Same for the status bar, but in the bottom
  • The web view is the most important part and should take as much space as possible
  • Buttons shouldn't resize at all, but we want them ...

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.