Example usage for javafx.stage Stage setScene

List of usage examples for javafx.stage Stage setScene

Introduction

In this page you can find the example usage for javafx.stage Stage setScene.

Prototype

@Override
final public void setScene(Scene value) 

Source Link

Document

Specify the scene to be used on this stage.

Usage

From source file:Main.java

/**
 * Creates a popup containing error without any pretty things for a graphical way to show errors
 * @param error Error string to show//from ww w .  java  2  s  .  c  om
 */
public static void showError(String error) {
    if (Platform.isFxApplicationThread()) {
        Stage s = new Stage();
        VBox v = new VBox();
        v.getChildren().add(new Label("Error [" + error + ']'));
        Scene sc = new Scene(v);
        s.setTitle("Fail");
        s.setScene(sc);
        s.show();
    } else {
        Platform.runLater(() -> {
            Stage s = new Stage();
            VBox v = new VBox();
            v.getChildren().add(new Label("Error [" + error + ']'));
            Scene sc = new Scene(v);
            s.setTitle("Fail");
            s.setScene(sc);
            s.show();
        });
    }
}

From source file:main.TestManager.java

/**
 * Displays a screen on which teacher can create a new test.
 * @param stage current stage//from  w  ww.  j  a va  2s.  c  o m
 */
public static void displayCreateNew(Stage stage) {
    try {
        Parent pane = FXMLLoader.load(TestManager.class.getResource("/resources/FXMLNewTest.fxml"));
        stage.setScene(new Scene(pane));
        stage.show();
    } catch (IOException e) {
        ErrorInformer.exitApp();
    }
}

From source file:jlotoprint.MainViewController.java

public static Stage loadTemplateChooser() {
    final Stage stage = new Stage();
    try {//from w w  w  .java 2  s . com
        FXMLLoader dialog = new FXMLLoader(MainViewController.class.getResource("TemplateDialog.fxml"));
        Parent root = (Parent) dialog.load();
        root.addEventHandler(TemplateDialogEvent.CANCELED, (actionEvent) -> {
            stage.close();
        });
        stage.setScene(new Scene(root));
        stage.setTitle("Choose a template");
        stage.getIcons().add(new Image("file:resources/icon.png"));
        stage.initModality(Modality.WINDOW_MODAL);
        stage.initOwner(JLotoPrint.stage.getScene().getWindow());
        stage.show();
    } catch (IOException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
    return stage;
}

From source file:Main.java

@Override
public void start(Stage stage) throws Exception {
    stage.setScene(new Scene(new Group(), 400, 100));
    stage.setTitle("Using Platform.runLater() Method");
    stage.show();//from w w  w  .  j  a v a  2 s  .  c o  m
}

From source file:org.kordamp.javatrove.example04.Launcher.java

@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setScene(view.createScene());
    primaryStage.sizeToScene();//  www.j  a  va  2  s  . c  o m
    primaryStage.setResizable(false);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.setTitle("Depth Buffer");
    stage.setScene(makeScene());
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.setTitle("Rotations");
    stage.setScene(makeScene());
    stage.show();/*from w  w  w . j av  a2s .c  o  m*/
    TimelineBuilder.create().cycleCount(Timeline.INDEFINITE).keyFrames(
            new KeyFrame(Duration.seconds(0), new KeyValue(translateZForNode1, -100), new KeyValue(angle, 0)),
            new KeyFrame(Duration.seconds(2), new KeyValue(translateZForNode1, 100), new KeyValue(angle, 180)),
            new KeyFrame(Duration.seconds(4), new KeyValue(translateZForNode1, -100), new KeyValue(angle, 360))

    ).build().play();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 200);
    stage.setScene(scene);

    ScrollBar s1 = new ScrollBar();

    root.getChildren().add(s1);//from ww  w .  j  a va 2  s .  com
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setScene(scene);
    stage.show();//from w ww. j ava  2s .c om

    stage.setWidth(300);
    stage.setHeight(200);

    final String[] greetings = new String[] { "Hello", "Hola", "1", "2" };
    final ChoiceBox cb = new ChoiceBox(FXCollections.observableArrayList("1", "2", "3", "4"));
    cb.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
        public void changed(ObservableValue ov, Number value, Number new_value) {
            System.out.println(new_value.intValue());
        }
    });

    cb.setValue("2");
    HBox hb = new HBox();
    hb.getChildren().addAll(cb);
    hb.setSpacing(30);
    hb.setAlignment(Pos.CENTER);
    hb.setPadding(new Insets(10, 0, 0, 10));

    ((Group) scene.getRoot()).getChildren().add(hb);

}

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox vbox = new VBox(20);
    Scene scene = new Scene(vbox, 400, 400);
    stage.setScene(scene);

    DatePicker checkInDatePicker = new DatePicker();

    vbox.getChildren().add(checkInDatePicker);

    stage.show();//from  w ww  .  j a  v a 2  s  . c  o m
}