25.4.7 Adding and Configuring a Label

Next, you’ll create the Label that displays "Welcome to JavaFX!":

1. Adding a Label to the VBox. Drag a Label from the Library window’s Controls section onto the VBox. The Label is automatically centered in the VBox because you set the VBox’s alignment to CENTER in Section 25.4.6.

2. Changing the Label’s text. You can set a Label’s text either by double clicking it and typing the text, or by selecting the Label and setting its Text property in the Inspector’s Properties section. Set the Label’s text to "Welcome to JavaFX!".

3. Changing the Label’s font. For this app, we set the Label to display in a large bold font. To do so, select the Label, then in the Inspector’s Preferences section, click the value ...

Get Java™ How To Program (Early Objects), Tenth Edition 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.