javafx.fxml.FXMLLoader.getRoot()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中javafx.fxml.FXMLLoader.getRoot()方法的一些代码示例,展示了FXMLLoader.getRoot()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FXMLLoader.getRoot()方法的具体详情如下:
包路径:javafx.fxml.FXMLLoader
类名称:FXMLLoader
方法名:getRoot

FXMLLoader.getRoot介绍

暂无

代码示例

代码示例来源:origin: de.roskenet/springboot-javafx-support

/**
 * Initializes the view by loading the FXML (if not happened yet) and
 * returns the top Node (parent) specified in the FXML file.
 *
 * @return the root view as determined from {@link FXMLLoader}.
 */
public Parent getView() {
  ensureFxmlLoaderInitialized();
  final Parent parent = fxmlLoader.getRoot();
  addCSSIfAvailable(parent);
  return parent;
}

代码示例来源:origin: com.airhacks/afterburner.fx

/**
 * Initializes the view by loading the FXML (if not happened yet) and
 * returns the top Node (parent) specified in
 *
 * @return the node loaded by FXMLLoader
 */
public Parent getView() {
  this.initializeFXMLLoader();
  Parent parent = fxmlLoader.getRoot();
  addCSSIfAvailable(parent);
  return parent;
}

代码示例来源:origin: org.codehaus.griffon/griffon-javafx

@Nonnull
protected Node loadFromFXML(@Nonnull String baseName) {
  requireNonBlank(baseName, "Argument 'baseName' must not be blank");
  if (baseName.endsWith(FXML_SUFFIX)) {
    baseName = stripFilenameExtension(baseName);
  }
  baseName = baseName.replace('.', '/');
  String viewName = baseName + FXML_SUFFIX;
  String styleName = baseName + ".css";
  URL viewResource = getResourceAsURL(viewName);
  if (viewResource == null) {
    throw new IllegalStateException("resource " + viewName + " not found");
  }
  FXMLLoader fxmlLoader = createFxmlLoader(viewResource);
  configureFxmlLoader(fxmlLoader);
  try {
    fxmlLoader.load();
  } catch (IOException e) {
    throw new GriffonException(e);
  }
  Parent node = fxmlLoader.getRoot();
  URL cssResource = getResourceAsURL(styleName);
  if (cssResource != null) {
    String uriToCss = cssResource.toExternalForm();
    node.getStylesheets().add(uriToCss);
  }
  return node;
}

相关文章