Book Image

Mastering JavaFX 10

By : Sergey Grinev
5 (1)
Book Image

Mastering JavaFX 10

5 (1)
By: Sergey Grinev

Overview of this book

: JavaFX 10 is used to create media-rich client applications. This book takes you on a journey to use JavaFX 10 to build applications that display information in a high-performance, modern user interface featuring audio, video, graphics, and animation. Mastering JavaFX 10 begins by introducing you to the JavaFX API. You will understand the steps involved in setting up your development environment and build the necessary dependencies. This is followed by exploring how to work with the assets, modules, and APIs of JavaFX. This book is filled with practical examples to guide you through the major features of JavaFX 10. In addition to this, you will acquire a practical understanding of JavaFX custom animations, merging different application layers smoothly, and creating a user-friendly GUI with ease. By the end of the book, you will be able to create a complete, feature-rich Java graphical application using JavaFX.
Table of Contents (15 chapters)

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 to stay at the same location

To achieve that, we put them all into AnchorPane and attach them to its borders correspondingly:

One way is to do it through an API, as in the following example:

AnchorPane root = new AnchorPane();
TextField...