Java Code Examples for javafx.scene.Scene#setRoot()

The following examples show how to use javafx.scene.Scene#setRoot() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ADCWindow.java    From arma-dialog-creator with MIT License 7 votes vote down vote up
public void initialize() {
	preInit = false;
	rootElement = new VBox();
	Scene scene = stage.getScene();
	scene.setRoot(rootElement);

	FXUtil.runWhenVisible(rootElement, new Runnable() {
		@Override
		public void run() {
			canvasView = new ADCCanvasView();
			mainMenuBar = new ADCMenuBar();

			rootElement.getChildren().addAll(mainMenuBar, canvasView);

			//force canvas to render at proper size
			autoResizeCanvasView();
		}
	});


	EventHandler<KeyEvent> keyEvent = new EventHandler<KeyEvent>() {
		@Override
		public void handle(KeyEvent event) {
			canvasView.keyEvent(event.getText(), event.getEventType() == KeyEvent.KEY_PRESSED, event.isShiftDown(), event.isControlDown(), event.isAltDown());
		}
	};
	scene.setOnKeyPressed(keyEvent);
	scene.setOnKeyReleased(keyEvent);
	scene.getMnemonics().clear();

}
 
Example 2
Source File: JarUpdater.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void showWaitingWindow(Stage stage) {
    stage.setTitle("Applying Updates");
    VBox windowMainLayout = new VBox();
    Group root = new Group();
    Scene scene = new Scene(root);
    stage.setScene(scene);
    scene.setRoot(windowMainLayout);

    Label updatingLabel = new Label();
    updatingLabel.setText("Please wait. HubTurbo is being updated...");
    updatingLabel.setPadding(new Insets(50));

    windowMainLayout.getChildren().addAll(updatingLabel);

    stage.show();
}
 
Example 3
Source File: ACEEditorSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage stage) throws IOException {
    INITIAL_TEXT = new String(IOUtils.toByteArray(ACEEditorSample.class.getResourceAsStream("/aceeditor.js")));
    stage.setTitle("HTMLEditor Sample");
    stage.setWidth(650);
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox root = new VBox();
    root.setPadding(new Insets(8, 8, 8, 8));
    root.setSpacing(5);
    root.setAlignment(Pos.BOTTOM_LEFT);

    final ACEEditor htmlEditor = new ACEEditor(true, 1, true);
    htmlEditor.setText(INITIAL_TEXT);
    htmlEditor.setMode("javascript");

    root.getChildren().addAll(htmlEditor.getNode());
    scene.setRoot(root);

    stage.setScene(scene);
    stage.show();
}
 
Example 4
Source File: Renderer.java    From strangefx with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void renderMeasuredProbabilities(int[] results) {
    CategoryAxis xAxis = new CategoryAxis();
    NumberAxis yAxis = new NumberAxis();
    BarChart<String, Integer> barChart = new BarChart(xAxis, yAxis);
    barChart.setData(getChartData(results));
    barChart.setTitle("Measured probability distribution");
    StackPane root = new StackPane();
    root.getChildren().add(barChart);
    if (myStage != null) {
        Scene oldscene = myStage.getScene();
        VBox box = (VBox)(oldscene.getRoot());
        oldscene.setRoot(new StackPane());
        box.getChildren().add(root);
        Scene newScene = new Scene(box);
        newScene.getStylesheets().add(Main.class.getResource("/styles.css").toExternalForm());
        myStage.setScene(newScene);
    } else {
        Stage stage = new Stage();
        stage.setScene(new Scene(root, 640, 480));
        stage.show();
    }

}
 
Example 5
Source File: AlterTopicDialog.java    From kafka-message-tool with MIT License 5 votes vote down vote up
private void prepareStage() {
    final Scene scene = new Scene(this);
    scene.getStylesheets().add(getClass().getResource(ApplicationConstants.GLOBAL_CSS_FILE_NAME).toExternalForm());
    scene.setRoot(this);
    stage.setScene(scene);
    stage.setTitle(String.format("Altering topic '%s'", topicAlterableProperties.getTopicName()));
    stage.setAlwaysOnTop(true);
    stage.setResizable(false);
}
 
Example 6
Source File: MainLauncher.java    From JavaFX-Chat with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStageObj = primaryStage;
    Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("views/LoginView.fxml"));
    primaryStage.initStyle(StageStyle.UNDECORATED);
    primaryStage.setTitle("Socket Chat : Client version 0.3");
    primaryStage.getIcons().add(new Image(getClass().getClassLoader().getResource("images/plug.png").toString()));
    Scene mainScene = new Scene(root, 350, 420);
    mainScene.setRoot(root);
    primaryStage.setResizable(false);
    primaryStage.setScene(mainScene);
    primaryStage.show();
    primaryStage.setOnCloseRequest(e -> Platform.exit());
}
 
Example 7
Source File: ProgressSample.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250);
    stage.setScene(scene);
    stage.setTitle("Progress Controls");

    for (int i = 0; i < values.length; i++) {
        final Label label = labels[i] = new Label();
        label.setText("progress:" + values[i]);

        final ProgressBar pb = pbs[i] = new ProgressBar();
        pb.setProgress(values[i]);

        final ProgressIndicator pin = pins[i] = new ProgressIndicator();
        pin.setProgress(values[i]);
        final HBox hb = hbs[i] = new HBox();
        hb.setSpacing(5);
        hb.setAlignment(Pos.CENTER);
        //hb.getChildren().addAll(label, pb, pin);
        hb.getChildren().addAll(pin);

    }

    final VBox vb = new VBox();
    vb.setSpacing(5);
    vb.getChildren().addAll(hbs);
    scene.setRoot(vb);
    stage.show();
}
 
Example 8
Source File: CustomTooltip.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
public CustomTooltip() {
    this.root = createRoot();
    this.root.setStyle("-fx-background-color: -var-menu-background-color;");

    final Scene scene = getScene();
    scene.setRoot(root);

    createContent(root);

    FXUtils.addClassTo(root, CssClasses.CUSTOM_TOOLTIP);
}
 
Example 9
Source File: PasswordFiledSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 260, 80);
    stage.setScene(scene);
    stage.setTitle("Password Field Sample");

    VBox vb = new VBox();
    vb.setPadding(new Insets(10, 0, 0, 10));
    vb.setSpacing(10);
    HBox hb = new HBox();
    hb.setSpacing(10);
    hb.setAlignment(Pos.CENTER_LEFT);

    Label label = new Label("Password");
    final PasswordField pb = new PasswordField();
    pb.setText("Your password");

    pb.setOnAction((ActionEvent e) -> {
        if (!pb.getText().equals("T2f$Ay!")) {
            message.setText("Your password is incorrect!");
            message.setTextFill(Color.rgb(210, 39, 30));
        } else {
            message.setText("Your password has been confirmed");
            message.setTextFill(Color.rgb(21, 117, 84));
        }
        pb.clear();
    });

    hb.getChildren().addAll(label, pb);
    vb.getChildren().addAll(hb, message);

    scene.setRoot(vb);
    stage.show();
}
 
Example 10
Source File: HTMLEditorSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) {
    stage.setTitle("HTMLEditor Sample");
    stage.setWidth(650);
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox root = new VBox();
    root.setPadding(new Insets(8, 8, 8, 8));
    root.setSpacing(5);
    root.setAlignment(Pos.BOTTOM_LEFT);

    final HTMLEditor htmlEditor = new HTMLEditor();
    htmlEditor.setPrefHeight(245);
    htmlEditor.setHtmlText(INITIAL_TEXT);

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setStyle("-fx-background-color: white");
    scrollPane.setContent(browser);
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefHeight(180);

    Button showHTMLButton = new Button("Load Content in Browser");
    root.setAlignment(Pos.CENTER);
    showHTMLButton.setOnAction((ActionEvent arg0) -> {
        webEngine.loadContent(htmlEditor.getHtmlText());
    });

    root.getChildren().addAll(htmlEditor, showHTMLButton, scrollPane);
    scene.setRoot(root);

    stage.setScene(scene);
    stage.show();
}
 
Example 11
Source File: ProgressSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250);
    stage.setScene(scene);
    stage.setTitle("Progress Controls");

    for (int i = 0; i < values.length; i++) {
        final Label label = labels[i] = new Label();
        label.setText("progress:" + values[i]);

        final ProgressBar pb = pbs[i] = new ProgressBar();
        pb.setProgress(values[i]);

        final ProgressIndicator pin = pins[i] = new ProgressIndicator();
        pin.setProgress(values[i]);
        final HBox hb = hbs[i] = new HBox();
        hb.setSpacing(5);
        hb.setAlignment(Pos.CENTER);
        hb.getChildren().addAll(label, pb, pin);
    }

    final VBox vb = new VBox();
    vb.setSpacing(5);
    vb.getChildren().addAll(hbs);
    scene.setRoot(vb);
    stage.show();
}
 
Example 12
Source File: SettingsWindow.java    From kafka-message-tool with MIT License 5 votes vote down vote up
private void setupStage(Window owner) {
    final Scene scene = new Scene(this);
    scene.getStylesheets().add(getClass().getResource(ApplicationConstants.GLOBAL_CSS_FILE_NAME).toExternalForm());
    scene.setRoot(this);
    stage.setScene(scene);
    stage.setTitle("Settings");
    stage.setResizable(false);
    stage.centerOnScreen();
    stage.initOwner(owner);
    stage.initModality(Modality.APPLICATION_MODAL);
}
 
Example 13
Source File: AboutWindow.java    From kafka-message-tool with MIT License 5 votes vote down vote up
private void setupStage(Window owner) {
    final Scene scene = new Scene(this);
    scene.getStylesheets().add(getClass().getResource(ApplicationConstants.GLOBAL_CSS_FILE_NAME).toExternalForm());
    scene.setRoot(this);
    stage.setScene(scene);
    stage.setTitle("About...");
    stage.setResizable(false);
    stage.centerOnScreen();
    stage.initOwner(owner);
    stage.initModality(Modality.APPLICATION_MODAL);
}
 
Example 14
Source File: AddTopicDialog.java    From kafka-message-tool with MIT License 5 votes vote down vote up
private void prepareStage() {
    final Scene scene = new Scene(this);
    scene.getStylesheets().add(getClass().getResource(ApplicationConstants.GLOBAL_CSS_FILE_NAME).toExternalForm());
    scene.setRoot(this);
    stage.setScene(scene);
    stage.setTitle("Creating new topic...");
    stage.setAlwaysOnTop(true);
    stage.setResizable(false);
}
 
Example 15
Source File: SeparatorSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 350, 150);
    stage.setScene(scene);
    stage.setTitle("Separator Sample");

    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setVgap(2);
    grid.setHgap(5);

    scene.setRoot(grid);
    scene.getStylesheets().add("separatorsample/controlStyle.css");

    Image cloudImage = new Image(getClass().getResourceAsStream("cloud.jpg"));
    Image sunImage = new Image(getClass().getResourceAsStream("sun.jpg"));

    caption.setFont(Font.font("Verdana", 20));

    GridPane.setConstraints(caption, 0, 0);
    GridPane.setColumnSpan(caption, 8);
    grid.getChildren().add(caption);

    final Separator sepHor = new Separator();
    sepHor.setValignment(VPos.CENTER);
    GridPane.setConstraints(sepHor, 0, 1);
    GridPane.setColumnSpan(sepHor, 7);
    grid.getChildren().add(sepHor);

    friday.setFont(Font.font("Verdana", 18));
    GridPane.setConstraints(friday, 0, 2);
    GridPane.setColumnSpan(friday, 2);
    grid.getChildren().add(friday);

    final Separator sepVert1 = new Separator();
    sepVert1.setOrientation(Orientation.VERTICAL);
    sepVert1.setValignment(VPos.CENTER);
    sepVert1.setPrefHeight(80);
    GridPane.setConstraints(sepVert1, 2, 2);
    GridPane.setRowSpan(sepVert1, 2);
    grid.getChildren().add(sepVert1);

    saturday.setFont(Font.font("Verdana", 18));
    GridPane.setConstraints(saturday, 3, 2);
    GridPane.setColumnSpan(saturday, 2);
    grid.getChildren().add(saturday);

    final Separator sepVert2 = new Separator();
    sepVert2.setOrientation(Orientation.VERTICAL);
    sepVert2.setValignment(VPos.CENTER);
    sepVert2.setPrefHeight(80);
    GridPane.setConstraints(sepVert2, 5, 2);
    GridPane.setRowSpan(sepVert2, 2);
    grid.getChildren().add(sepVert2);

    sunday.setFont(Font.font("Verdana", 18));
    GridPane.setConstraints(sunday, 6, 2);
    GridPane.setColumnSpan(sunday, 2);
    grid.getChildren().add(sunday);

    final ImageView cloud = new ImageView(cloudImage);
    GridPane.setConstraints(cloud, 0, 3);
    grid.getChildren().add(cloud);

    final Label t1 = new Label("16");
    t1.setFont(Font.font("Verdana", 20));
    GridPane.setConstraints(t1, 1, 3);
    grid.getChildren().add(t1);

    final ImageView sun1 = new ImageView(sunImage);
    GridPane.setConstraints(sun1, 3, 3);
    grid.getChildren().add(sun1);

    final Label t2 = new Label("18");
    t2.setFont(Font.font("Verdana", 20));
    GridPane.setConstraints(t2, 4, 3);
    grid.getChildren().add(t2);

    final ImageView sun2 = new ImageView(sunImage);
    GridPane.setConstraints(sun2, 6, 3);
    grid.getChildren().add(sun2);

    final Label t3 = new Label("20");
    t3.setFont(Font.font("Verdana", 20));
    GridPane.setConstraints(t3, 7, 3);
    grid.getChildren().add(t3);

    stage.show();
}
 
Example 16
Source File: LoginApplication.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 150);
    stage.setScene(scene);
    stage.setTitle("Text Field Sample");

    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setVgap(5);
    grid.setHgap(5);

    scene.setRoot(grid);

    final TextField name = new TextField();
    name.setPromptText("User Name:");
    HBox.setHgrow(name, Priority.ALWAYS);
    GridPane.setConstraints(name, 0, 0);
    grid.getChildren().add(name);

    final TextField lastName = new TextField();
    lastName.setPromptText("Password:");
    HBox.setHgrow(lastName, Priority.ALWAYS);
    GridPane.setConstraints(lastName, 0, 1);
    grid.getChildren().add(lastName);

    Button submit = new Button("Submit");
    GridPane.setConstraints(submit, 0, 2);
    grid.getChildren().add(submit);

    submit.setOnAction((ActionEvent e) -> {
        ProcessBuilder pb = new ProcessBuilder("java", "-cp", System.getProperty("java.class.path"),
                ButtonSample.class.getName());
        try {
            if (System.getenv("USER_JTO") != null) {
                pb.environment().put("JAVA_TOOL_OPTIONS", System.getenv("USER_JTO"));
            }
            Process process = pb.start();
            System.exit(0);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    });

    stage.show();
}
 
Example 17
Source File: UpdateProgressWindow.java    From HubTurbo with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void initProgressWindow() {
    Stage stage = new Stage();
    stage.setTitle(WINDOW_TITLE);

    windowMainLayout = new VBox();

    Group root = new Group();
    Scene scene = new Scene(root);
    stage.setScene(scene);

    scene.setRoot(windowMainLayout);

    window = stage;

    reloadWindowLayout();
}