Java Reference
In-Depth Information
<font>
<Font name="System Bold" size="100.0" />
</font>
</Text>
<VBox alignment="CENTER" spacing="10.0">
<children>
<Ellipse fx:id="whiteEllipse" fill="WHITE"
radiusX="32.0" radiusY="20.0" stroke="BLACK" strokeType="INSIDE" />
<Text fx:id="remainingWhite" fill="WHITE"
strokeType="OUTSIDE" strokeWidth="0.0" text="turns remaining">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Text>
</children>
</VBox>
</children>
</FlowPane>
</children>
</StackPane>
</children>
</TilePane>
</bottom>
</BorderPane>
<Button layoutX="520.0" layoutY="14.0" mnemonicParsing="false" onAction="#restart"
text="Restart" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" />
</children>
</AnchorPane>
This XML file was not hand-coded, but it is the result of a design process facilitated by ScreenBuilder 2, which
was discussed in Chapter 3.
We have the declaration of the UI in an FXML file, but we still need to wire the game logic together. An important
part of this wiring is the declaration of the Controller class, which is done near the top of the FXML file:
<AnchorPane ... fx:controller="projavafx.reversifxml.BoardController">
The BoardController is a new class that provides programmatic access to the components declared in the FXML file.
Listing 5-19 shows the content of this controller class.
Listing 5-19. Implementation of the Controller Class
public class BoardController {
private final ReversiModel model = ReversiModel.getInstance();
@FXML private TilePane titlePane;
@FXML private TilePane scorePane;
@FXML private StackPane centerPane;
@FXML private Text scoreBlack;
@FXML private Text scoreWhite;
@FXML private Text remainingBlack;
@FXML private Text remainingWhite;
 
Search WWH ::




Custom Search