Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.layout.StackPane;
- import javafx.scene.text.Text;
- import javafx.stage.Stage;
- /**
- *
- * @author zoranpavlovic.blogspot.com
- */
- public class CreateDialog extends Application {
- /**
- * @param args
- * the command line arguments
- */
- public static void main(String[] args) {
- Application.launch(args);
- }
- @Override
- public void start(final Stage primaryStage) {
- primaryStage.setTitle("Dialog");
- StackPane sp = new StackPane();
- Button btnOpen = new Button("Open Dialog");
- sp.getChildren().add(btnOpen);
- // Add action to open a new dialog
- btnOpen.setOnAction(new EventHandler<ActionEvent>() {
- public void handle(ActionEvent event) {
- // Creating a new Stage and showing it
- Stage stage = new Stage();
- Scene page2 = new Scene(new Group(new Text(20, 20,"This is a new dialog!")));
- stage.setScene(page2);
- stage.show();
- }
- });
- // Adding StackPane to the scene
- Scene scene = new Scene(sp, 300, 200);
- primaryStage.setScene(scene);
- primaryStage.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement