Lesson 18Introduction to GUI with JavaFX
JavaFX was created to compete with formerly popular Rich Internet Application (RIA) frameworks, such as Adobe Flex and Microsoft Silverlight. In reality JavaFX never became competitive in the RIA space, but it presents a better and more modern alternative for Swing when it comes to developing a graphical user interface (GUI) in Java. Whereas Swing was built on top of the old AWT library, JavaFX is not. Also, while JavaFX is bundled with Java SE 8, it’s not a part of it.
With JavaFX you can develop the GUI either in Java or use a mix of FXML and Java. The FXML is an XML-based markup language that enables you to define GUI components in a declarative way. The sources of such GUI definitions would be stored in a text files with the extension .fxml
, which represent a view in the Model View Controller (MVC) architecture. The business code and access to data would be still written in Java using a rich library of JavaFX components. Using FXML for GUI promotes the clean separation of the code between the MVC layers. JavaFX offers a design tool called Scene Builder that allows designing the GUI by dragging the GUI components from a toolbar onto the window’s real estate.
In this lesson you’ll learn how to program JavaFX application in Java. In Lesson 19 you’ll see how to use Scene Builder to make a GUI design process a lot more enjoyable and simple by using FXML.
You can find JavaFX documentation at the following Oracle website: http://docs.oracle.com/javase/8/javase-clienttechnologies.htm ...
Get Java Programming 24-Hour Trainer, 2nd 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.