All Classes Namespaces Files Functions Variables
InputMain.java
Go to the documentation of this file.
1 package dialogs;
2 import javafx.application.Application;
3 import javafx.stage.Stage;
4 import javafx.scene.Scene;
5 import javafx.scene.control.TextInputDialog;
6 import javafx.scene.layout.BorderPane;
7 
8 import java.util.Optional;
9 
10 
11 @SuppressWarnings("javadoc")
12 public class InputMain extends Application {
13  @Override
14  public void start(Stage stage) {
15  BorderPane root = new BorderPane();
16  Scene scene = new Scene(root, 400, 400);
17  stage.setScene(scene);
18  stage.setTitle("BorderPane");
19  stage.show();
20 
21  TextInputDialog dialog = new TextInputDialog("kelmit");
22  dialog.setHeaderText(null);
23  dialog.setTitle("Vastaa");
24  dialog.setContentText("Kerhon nimi:");
25  Optional<String> answer = dialog.showAndWait();
26  System.out.println(answer.isPresent() ? answer.get() : "Ei ollut vastausta");
27  }
28 
29  public static void main(String[] args) { launch(args); }
30 }