Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 21 ■ Questions and answers: Finishing the setup Methods and digital audio

Adding Answer Button Content to setupQSgameplay() Methods


Now we are in a position where we can simply add the Q&A UI Panel answers for each game board square
by adding four relatively simple Java statements to the inside of each of the if(pickSn == n) conditional if()
evaluation statements inside each of the setupQSgameplay() method bodies. To test our user interface with
real answer data, all we need to do is to add the first setupQ1S1gameplay() if (pickS1 == 0) section, adding
the four setText() method calls to the diffuse and Shader21 object configurations that are already in place in
this section of code to control your imagery.
The Java code, also shown at the end of Figure 21-20, should look like the following:


private void setupQ1S1gameplay() {
if (pickS1 == 0) {
diffuse21 = new Image("gamequad1bird0.png", 512, 512, true, true, true);
Shader21.setDiffuseMap(diffuse21);
a1Button.setText("Falcon Hawk");
a2Button.setText("Seagull");
a3Button.setText("Peacock");
a4Button.setText("Flamingo");
}
}


Figure 21-19. Use a Run ➤ Project work process to see if the Q&A panel layout has been restored to its large
readable state

Free download pdf