package class10_1_JavaFXTwoWindows; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.effect.BoxBlur; import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class Main extends Application { private Label label; private Stage secondaryStage; @Override public void start(Stage primaryStage) throws Exception{ Pane root = new VBox(); label = new Label("This is a lot of text that will show up on the screen!"); Button setupWindowButton = new Button("Setup Window"); setupWindowButton.setOnAction(e->secondaryStage.show()); root.getChildren().addAll(label,setupWindowButton); primaryStage.setTitle("Hello World"); primaryStage.setScene(new Scene(root, 300, 50)); setupSecondWindow(); primaryStage.show(); } private void setupSecondWindow() { Pane root = new StackPane(); Button clickMe = new Button("Click Me!"); clickMe.setOnAction(new MyHandler()); root.getChildren().addAll(clickMe); secondaryStage = new Stage(); secondaryStage.setScene(new Scene(root, 300, 50)); } public static void main(String[] args) { launch(args); } public class MyHandler implements EventHandler { public void handle(ActionEvent e) { System.out.println("The button was pressed!"); System.out.println(label.getText()); if(label.getEffect() == null) { label.setEffect(new BoxBlur()); } else { label.setEffect(null); } } } }