当前位置: 首页>>代码示例>>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;未经允许,请勿转载。