Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 9 ■ JavaFX 9 User InterFaCe DesIgn: the Front enD For Java 9 game DesIgn


The next thing you may want to do is to make the Button Controls uniform in width, which you’ll
accomplish by using a Button.setMaxWidth() method. When you upgrade your Scene object constructor to
support iTV 1280x720, you’ll be able to see the TOP_RIGHT Pos constant in action, and a uniform block of
buttons will look more professional.


Using a Button.setMaxWidth() Method: Making Buttons Uniform


The first thing that you will need to do is to set the scene Scene object to an iTV width of 1280 and a height of
640 so that you are using a wide 2:1 aspect ratio and have the minimum supported iTV screen resolution for
your pro Java 9 game application. As you can see in Figure 9-9, I upgraded the Scene() constructor method to
use these new application window screen dimensions in the following Java code, shown on line 83 at the top
of Figure 9-9:


scene = new Scene(root, 1280 , 640 );


The next thing that you’ll do is to set the boardGameBackPlate ImageView to contain the welcome
message image. You’ll do this using a .setImage() method with the splashScreen Image, using this code on
line 89 in Figure 9-9:


boardGameBackPlate.setImage(splashScreen);


Finally, to make the Button objects 125 pixels in uniform width, use the .setMaxWidth(125) method
call, called off of each of the five Button UI objects (as shown in Figure 9-9, on code lines 97, 100, 103, 106,
and 109).


Figure 9-9. Use the .setMaxWidth() method call to set your Button UI objects to 125 so that they have a
uniform width

Free download pdf