13.3 Welcome to JavaFX Program 2
Cliquez içi pour plus de vidéos disponibles sur notre chaine youtube !All right, in this video we’ll see how to do the same in the fxml file. So first, I’m going to unpack the loading of fxml here and I’m going to comment on all these additional commands. And here I’m going to change the root to this load() variable When we run it again, we should now get an empty window again. All right now let’s go to the fxml file. So let’s, insert the label So, Label Text = "Welcome to javaFx" First of all, if we execute this, we can see our welcome text on javaFX So now let’s define the color and font of the text. So, to set the color to green, we need to set the label property we will add textFill = "green" So this is the color Then we need to add a font. And we have to do that by adding a child-to-label font. So we have to go down here and type and then we have to configure the font. So let’s add another font Font inside this font and this time F upper case and not lower case. Name = Times New Romans bold And then after the size of the text so size = " 70" So let’s run the application now. We have pretty much the same application this time using the fxml file instead of the manual controls we did in the code previously. So, when you define a user interface control using fxml, we can always change its properties in the code. For example, we may want to enable or disable buttons to respond to a user action. So as you’ve seen, we can create the user interface. By creating user interface controls via the codes and defining their properties, or we can do it via the fxml file. All right. So that was a brief introduction to javaFx Let’s finish the video here. And in the next video, let’s take a look at the javaFx layouts Go I tell you to next.