12.10 Building a GUI Programmatically
We have been defining GUIs using FXML, which works well when we know the number and type of controls in our GUI. Sometimes, however, the GUI is dynamic and because we may not know how many buttons or other controls we need until runtime, we must define the GUI, that is, instantiate the controls and set their properties, programmatically. For example, the GUI may include buttons that represent URL links stored in a file or on a web server. In that case, the number of buttons can vary each time we run our application. In other applications, it may be more convenient to build the GUI by code rather than with FXML. For example, if the GUI represents a tic-tac-toe game or a chessboard, it is convenient to represent ...
Get Java Illuminated, 5th 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.