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


Java Scene.getRoot方法代碼示例

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


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

示例1: showMenuBar

import javafx.scene.Scene; //導入方法依賴的package包/類
/**
 * show or hide the menuBar
 * 
 * @param scene
 * @param pMenuBar
 */
public void showMenuBar(Scene scene, MenuBar pMenuBar, boolean show) {
  Parent sroot = scene.getRoot();
  ObservableList<Node> rootChilds = null;
  if (sroot instanceof VBox)
    rootChilds = ((VBox) sroot).getChildren();
  if (rootChilds == null)
    throw new RuntimeException(
        "showMenuBar can not handle scene root of type "
            + sroot.getClass().getName());
  if (!show && rootChilds.contains(pMenuBar)) {
    rootChilds.remove(pMenuBar);
  } else if (show) {
    rootChilds.add(0, pMenuBar);
  }
  pMenuBar.setVisible(show);
  hideMenuButton
      .setText(show ? I18n.get(I18n.HIDE_MENU) : I18n.get(I18n.SHOW_MENU));
}
 
開發者ID:BITPlan,項目名稱:can4eve,代碼行數:25,代碼來源:JavaFXDisplay.java

示例2: doBlockingAsyncWork

import javafx.scene.Scene; //導入方法依賴的package包/類
public static <T extends Object> void doBlockingAsyncWork(Scene scene, Supplier<T> action, Consumer<T> success,
		Consumer<Throwable> error) {
	Parent originalRoot = scene.getRoot();
	Runnable blockScreen = () -> originalRoot.setDisable(true);
	Runnable unblockScreen = () -> originalRoot.setDisable(false);

	Task<T> task = new Task<T>() {
		@Override
		protected T call() throws Exception {
			blockScreen.run();
			return action.get();
		}

		@Override
		protected void succeeded() {
			unblockScreen.run();
			success.accept(getValue());
		}

		@Override
		protected void failed() {
			unblockScreen.run();
			error.accept(getException());
		}
	};
	Thread t = new Thread(task);
	t.setDaemon(true);
	t.start();
}
 
開發者ID:jesuino,項目名稱:java-ml-projects,代碼行數:30,代碼來源:AppUtils.java

示例3: displayText

import javafx.scene.Scene; //導入方法依賴的package包/類
private void displayText(final String s, final String title) {
	final Scene scene = new Scene(new Pane());

	String text = s;
	if (s == null || s.isEmpty()) { text = "Whoops! Nothing to see here"; }
	final Text textItem = new Text(text);

	final Button okButton = new Button("OK");

	final GridPane grid = new GridPane();
	grid.setVgap(4);
	grid.setHgap(10);
	grid.setPadding(new Insets(5, 5, 5, 5));
	grid.add(textItem, 0, 0);
	grid.add(okButton, 1, 0);

	final Pane root = (Pane) scene.getRoot();
	root.getChildren().add(grid);

	if (rootModel.darkModeProperty().get()) {
		scene.getStylesheets().add("root/darkMode.css");
		textItem.getStyleClass().add("text");
	}

	final Stage stage = new Stage();
	stage.setScene(scene);
	stage.setTitle(title);
	stage.show();


	okButton.setOnAction(e -> {
		stage.close();
	});
}
 
開發者ID:jakemanning,項目名稱:boomer-tuner,代碼行數:35,代碼來源:RootController.java

示例4: start

import javafx.scene.Scene; //導入方法依賴的package包/類
@Override public void start(Stage stage) {
    stage.setTitle("TitledPane");
    Scene scene = new Scene(new Group(), 450, 250);

    TitledPane gridTitlePane = new TitledPane();
    GridPane grid = new GridPane();
    grid.setVgap(4);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("First Name: "), 0, 0);
    grid.add(new TextField(), 1, 0);
    grid.add(new Label("Last Name: "), 0, 1);
    grid.add(new TextField(), 1, 1);
    grid.add(new Label("Email: "), 0, 2);
    grid.add(new TextField(), 1, 2);        
    grid.add(new Label("Attachment: "), 0, 3);
    grid.add(label,1, 3);
    gridTitlePane.setText("Grid");
    gridTitlePane.setContent(grid);

    final Accordion accordion = new Accordion ();      
    
    for (int i = 0; i < imageNames.length; i++) {
        images[i] = 
            new Image(getClass().getResourceAsStream(imageNames[i]+".jpg"));
        pics[i] = new ImageView(images[i]);
        tps[i] = new TitledPane(imageNames[i],pics[i]); 
    }   
    accordion.getPanes().addAll(tps);
    

    accordion.expandedPaneProperty().addListener(
        (ObservableValue<? extends TitledPane> ov, TitledPane old_val, 
        TitledPane new_val) -> {
            if (new_val != null) {
                label.setText(accordion.getExpandedPane().getText()
                        + ".jpg");
            }
    });
    
    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(gridTitlePane, accordion);

    Group root = (Group)scene.getRoot();
    root.getChildren().add(hbox);
    stage.setScene(scene);
    stage.show();
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:49,代碼來源:TitledPaneSample.java

示例5: createPlaylistName

import javafx.scene.Scene; //導入方法依賴的package包/類
public void createPlaylistName(final ObservableList<Song> selectedCells) {
    Scene scene = new Scene(new Pane());

    TextField textField = new TextField ();
    Button createButton = new Button("Create");
    Label label = new Label("Playlist Name: ");

    GridPane grid = new GridPane();
    grid.setVgap(4);
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(label, 0, 0);
    grid.add(textField, 1, 0);
    grid.add(createButton, 2, 0);

    Pane root = (Pane)scene.getRoot();
    root.getChildren().add(grid);

    if (rootModel.darkModeProperty().get()) {
        scene.getStylesheets().add("root/darkMode.css");
        grid.getStyleClass().add("background-root");
    }

    Stage stage = new Stage();
    stage.setScene(scene);
    stage.setTitle("Create Your Playlist");
    stage.show();
    stage.setOnCloseRequest(event -> {
        getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
        getSelectionModel().selectedItemProperty().addListener(songListener);
    });

    createButton.setOnAction(e -> {
        playlistCreated(textField.getText(), selectedCells, stage);
    });

    textField.setOnKeyPressed(ke -> {
        if (ke.getCode().equals(KeyCode.ENTER)) {
            playlistCreated(textField.getText(), selectedCells, stage);
        }
    });
}
 
開發者ID:jakemanning,項目名稱:boomer-tuner,代碼行數:43,代碼來源:SongsView.java


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