In previous recipes in this chapter, we have used the standard JavaFX controls to create application GUIs. Inevitably, you will have an idea for a component with specific behaviors and usage not offered by the standard set of controls. What do you do? Fortunately, creating your own control is as easy as creating a new class. In this recipe, you will learn how to create your own reusable GUI control.
As mentioned in the introduction for this recipe, creating a custom control is as easy as creating a new class. If you are not familiar with the topic of class creation and issues with accessibility and visibility of class members, review the recipes Declaring and using JavaFX classes from Chapter 1, Creating your own custom node from Chapter 2, and Making your scripts modular, also from Chapter 2. If you are not familiar with the JavaFX Control API, review the recipe Creating a form with JavaFX controls from this chapter.