javafx.scene.Scene#setRoot ( )源码实例Demo

下面列出了javafx.scene.Scene#setRoot ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: arma-dialog-creator   文件: ADCWindow.java
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();

}
 
源代码2 项目: marathonv5   文件: ACEEditorSample.java
@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();
}
 
源代码3 项目: strangefx   文件: Renderer.java
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();
    }

}
 
源代码4 项目: HubTurbo   文件: JarUpdater.java
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();
}
 
源代码5 项目: kafka-message-tool   文件: AddTopicDialog.java
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);
}
 
源代码6 项目: kafka-message-tool   文件: AlterTopicDialog.java
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);
}
 
源代码7 项目: kafka-message-tool   文件: AboutWindow.java
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);
}
 
源代码8 项目: kafka-message-tool   文件: SettingsWindow.java
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);
}
 
源代码9 项目: marathonv5   文件: ProgressSample.java
@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();
}
 
源代码10 项目: marathonv5   文件: HTMLEditorSample.java
@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();
}
 
源代码11 项目: marathonv5   文件: PasswordFiledSample.java
@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();
}
 
源代码12 项目: jmonkeybuilder   文件: CustomTooltip.java
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);
}
 
源代码13 项目: mars-sim   文件: ProgressSample.java
@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();
}
 
源代码14 项目: JavaFX-Chat   文件: MainLauncher.java
@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());
}
 
源代码15 项目: marathonv5   文件: LoginApplication.java
@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();
}
 
源代码16 项目: marathonv5   文件: SeparatorSample.java
@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();
}
 
源代码17 项目: HubTurbo   文件: UpdateProgressWindow.java
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();
}