當前位置: 首頁>>代碼示例>>Java>>正文


Java Scene.setRoot方法代碼示例

本文整理匯總了Java中javafx.scene.Scene.setRoot方法的典型用法代碼示例。如果您正苦於以下問題:Java Scene.setRoot方法的具體用法?Java Scene.setRoot怎麽用?Java Scene.setRoot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.Scene的用法示例。


在下文中一共展示了Scene.setRoot方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: start

import javafx.scene.Scene; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {

    this.primaryStage = primaryStage;
    Parent root = new AnchorPane();
    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.getIcons().add(new Image(SQUID_LOGO_SANS_TEXT_URL));
    primaryStage.setTitle("Squid 3.0 pre-release");

    // this produces non-null window after .show()
    primaryStageWindow = primaryStage.getScene().getWindow();

    primaryStage.setOnCloseRequest((WindowEvent e) -> {
        Platform.exit();
        System.exit(0);
    });

    // postpone loading to allow for stage creation and use in controller
    scene.setRoot(FXMLLoader.load(getClass().getResource("SquidUIController.fxml")));
    primaryStage.show();
    primaryStage.setMinHeight(scene.getHeight() + 15);
    primaryStage.setMinWidth(scene.getWidth());

    squidAboutWindow = new SquidAboutWindow(primaryStage);
}
 
開發者ID:CIRDLES,項目名稱:Squid,代碼行數:27,代碼來源:SquidUI.java

示例2: start

import javafx.scene.Scene; //導入方法依賴的package包/類
@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();
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:29,代碼來源:ProgressSample.java

示例3: start

import javafx.scene.Scene; //導入方法依賴的package包/類
@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();
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:40,代碼來源:HTMLEditorSample.java

示例4: start

import javafx.scene.Scene; //導入方法依賴的package包/類
@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();
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:36,代碼來源:PasswordFiledSample.java

示例5: CustomTooltip

import javafx.scene.Scene; //導入方法依賴的package包/類
/**
 * Instantiates a new Custom tooltip.
 */
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);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:15,代碼來源:CustomTooltip.java


注:本文中的javafx.scene.Scene.setRoot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。