From the course: Learning JavaFX GUI Development

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Use UI control event handlers

Use UI control event handlers

- [Voiceover] Now that we've seen the many possible UI controls that we can include, let's create a sample application with some of the controls and include logic to handle events generated by these components. One of the most commonly used controls is the button. The button class is an extension of the label class. Buttons can be displayed with text, with text and an image, or just an image. They can be styled with color and fonts using CSS and buttons use three constructors. The same as a label. You can create an empty button, a button with text, and a button with text and an image. Once a button is created, we can also use these set text and set graphic methods to add text or an image to our button. Buttons have three states. When the mouse is over the button, when the mouse is not over the button, and the action of clicking the button. The set on action method is used to handle a button click. Now it's time to switch…

Contents