Lab05 Agenda
Lab05 Agenda
(12h30-1h15)
(1h15 - 2h00)
@Override
public void start(Stage primaryStage) {
// Construct the "Button" and attach an "EventHandler"
btnHello = new Button();
btnHello.setText("Say Hello");
// Using JDK 8 Lambda Expression to construct an EventHandler<ActionEvent>
btnHello.setOnAction(evt -> System.out.println("Hello World!"));
Scene scene = new Scene(root, 300, 100); // Construct a scene given the root of scene graph
primaryStage.setScene(scene); // The stage sets scene
primaryStage.setTitle("Hello"); // Set window's title
primaryStage.show(); // Set visible (show it)
}
@Override
public void start(Stage primaryStage) {
......
// Construct a scene with the root of the scene graph, width and height
Scene scene = new Scene(root, 300, 100);
// Set the scene of the stage
primaryStage.setScene(scene);
// Set the window title
primaryStage.setTitle("Hello");
// Show the stage
primaryStage.show();
}
An exception is an event that occurs in the execution of a program and it breaks the expected flow of the
program.
Tutorial: https://dev.java/learn/exceptions/