Let's see how skins work using our ClockControl demo. We will create two different skins for it and will provide an option to switch between them.
Our skins will be called Hands and Text—let's start with the control that will manage them and other ClockControl logic. Note the next points:
- As we are making a proper control now, we can extend the javafx.scene.control.Control itself.
- This implements the Skinnable interface to work with skins.
- As a Model, our ClockControl holds the data—the current time in the timeProp field.
- As a Controller, our ClockControl handles the business logic—updating the timeProp field.
- We have a good MVC separation now—our skins will not know how timeProp is managed. So, if you decide to move it ...