Java Graphics Toolkits Age

Cards (12)

  • javas GUI toolkit order: AWT -> Swing -> JavaFX
  • java 11 brought in modules, ending built in javafx
  • stage = window. at any time can have (any) one scene on the stage (can switch)
  • Panes = containers (eg. grid pane) and can be nested
  • event listener objects watch for and execute commands on keyboard/mouse input (eg. on-OK-button-clicked event listener)
  • just create new eventHandlers (what to do once triggered) at the point of creating the event listener
  • event handlers are created as anonymous inner classes (no name)
  • borderPane = the 4 edges and a centre, Hbox/VBox = horizontal/vertical row, StackPane = stacks nodes literally on top of each other (layers them), GridPane = cells in a table basically, FlowPLane, TilePlane = goes across horizontally/vertically until reaches edge and then wraps back to start next line, AnchorPane = sticks to an edge
  • FXML - XML based language, specify structure of the UI in an xml file, thus separating it from code. Uses controllers to handle events (based on Model-View-Controller design pattern)
  • FXML pros: less text so easier to visualise the design, not compiled so do not need to recompile to see changes, can use Scene Builder tool to generate FXML, encapsulation
  • Canvas - another visual NODE that allows creation of images using simple drawing shapes (line, rectangle) and can be combined with other classes to create effects like blending.
  • canvas is a node, with the image data stored in a buffer that is encapsulated in a GraphicContext object (access this to call methods to do stuff like change stroke colour for lines, fill colour for chapes from said call onwards)