import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class clickMe extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Click Me");
Group group=new Group();
Scene scene=new Scene(group,400,400);
Button button=new Button("Please click me");
button.setLayoutX(120);
button.setLayoutY(180);
button.setPrefSize(160,40);
group.getChildren().add(button);
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
Stage msgBox=new Stage();
Group msgGroup=new Group();
Scene scene1=new Scene(msgGroup,230,150);
Label label=new Label("Clicked!!!");
label.setLayoutX(80);
label.setLayoutY(60);
msgGroup.getChildren().add(label);
msgBox.setScene(scene1);
msgBox.show();
}
});
primaryStage.setScene(scene);
primaryStage.show();
}
}