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

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

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

FXMLLoader.load介绍

暂无

代码示例

代码示例来源:origin: speedment/speedment

@Override
public Node load(String name) {
  final FXMLLoader loader = fxmlLoader();
  final String filename = FXML_PREFIX + name + FXML_SUFFIX;
  loader.setLocation(InjectionLoaderImpl.class.getResource(filename));
  
  try {
    return loader.load();
  } catch (final IOException ex) {
    throw new SpeedmentToolException(
      "Error! Could not find FXML-file: " + filename + ".", ex
    );
  }
}

代码示例来源:origin: jfoenixadmin/JFoenix

/**
   * init fxml when loaded.
   */
  @PostConstruct
  public void init() {
    try {
      popup = new JFXPopup(FXMLLoader.load(getClass().getResource("/fxml/ui/popup/DemoPopup.fxml")));
    } catch (IOException ioExc) {
      ioExc.printStackTrace();
    }
    burger1.setOnMouseClicked((e) -> popup.show(rippler1, PopupVPosition.TOP, PopupHPosition.LEFT));
    burger2.setOnMouseClicked((e) -> popup.show(rippler2, PopupVPosition.TOP, PopupHPosition.RIGHT));
    burger3.setOnMouseClicked((e) -> popup.show(rippler3, PopupVPosition.BOTTOM, PopupHPosition.LEFT));
    burger4.setOnMouseClicked((e) -> popup.show(rippler4, PopupVPosition.BOTTOM, PopupHPosition.RIGHT));
  }
}

代码示例来源:origin: pmd/pmd

public void showExportXPathToRuleWizard() {
  ExportXPathWizardController wizard
    = new ExportXPathWizardController(xpathExpressionProperty());
  FXMLLoader loader = new FXMLLoader(getClass().getResource("fxml/xpath-export-wizard.fxml"));
  loader.setController(wizard);
  final Stage dialog = new Stage();
  dialog.initOwner(designerRoot.getMainStage());
  dialog.setOnCloseRequest(e -> wizard.shutdown());
  dialog.initModality(Modality.WINDOW_MODAL);
  Parent root;
  try {
    root = loader.load();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  Scene scene = new Scene(root);
  //stage.setTitle("PMD Rule Designer (v " + PMD.VERSION + ')');
  dialog.setScene(scene);
  dialog.show();
}

代码示例来源:origin: pmd/pmd

private Stage createStage(Stage mainStage) {
  FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("event-log.fxml"));
  loader.setController(this);
  final Stage dialog = new Stage();
  dialog.initOwner(mainStage.getScene().getWindow());
  dialog.initModality(Modality.NONE);
  Parent root;
  try {
    root = loader.load();
  } catch (IOException e) {
    throw new IllegalStateException(e);
  }
  Scene scene = new Scene(root);
  dialog.setScene(scene);
  return dialog;
}

代码示例来源:origin: speedment/speedment

notification = loader.load();
} catch (final IOException ex) {
  throw new SpeedmentToolException(

代码示例来源:origin: pmd/pmd

stage.setScene(new Scene(fxmlLoader.load()));
} catch (IOException e) {
  e.printStackTrace();

代码示例来源:origin: pmd/pmd

Parent root = loader.load();
Scene scene = new Scene(root);

代码示例来源:origin: pmd/pmd

private Stage createEditPropertyDialog() {
  EditPropertyDialogController wizard = new EditPropertyDialogController();
  FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("edit-property-dialog.fxml"));
  loader.setController(wizard);
  final Stage dialog = new Stage();
  dialog.initOwner(this.getScene().getWindow());
  dialog.initModality(Modality.WINDOW_MODAL);
  dialog.initStyle(StageStyle.UNDECORATED);
  Parent root;
  try {
    root = loader.load();
  } catch (IOException e) {
    throw new IllegalStateException(e);
  }
  Scene scene = new Scene(root);
  dialog.setTitle("Edit property");
  dialog.setScene(scene);
  dialog.setUserData(wizard);
  return dialog;
}

代码示例来源:origin: pmd/pmd

Stage popup = new Stage();
FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("generate-xpath-from-stack-trace.fxml"));
Parent root = loader.load();
Button button = (Button) loader.getNamespace().get("generateButton");
TextArea area = (TextArea) loader.getNamespace().get("stackTraceArea");

代码示例来源:origin: jfoenixadmin/JFoenix

toolbarPopup = new JFXPopup(loader.load());

代码示例来源:origin: net.sf.gluebooster.java.booster/gb-basic

/**
 * Loads and parses a fxml document.
 * 
 * @param fxml
 *            the stream containing the document
 * @param closeStream
 *            close the stream after processing
 */
public void load(InputStream fxml, boolean closeStream) throws Exception {
  FXMLLoader loader = new FXMLLoader();
  fxmlRoot = loader.load(fxml);
  if (closeStream)
    fxml.close();
}

代码示例来源:origin: com.vektorsoft.demux.desktop/demux-jfx-core

/**
 * Loads FXML object from URL specified in constructor.
 * 
 * @return valid JavaFX UI object
 * @throws IOException if an error occurs
 */
@Override
public Object load() throws IOException {
  setResources(new DMXResourceBundle(resourceHnadler));
  return super.load(fxmlFileUrl.openStream());
}

代码示例来源:origin: eu.agrosense.spi/session

public WorldPane() {
  log.finest("constructing world pane");
  FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("WorldPane.fxml"));
  fxmlLoader.setRoot(this);
  fxmlLoader.setController(this);
  try {
    fxmlLoader.load();
  } catch (IOException exception) {
    throw new RuntimeException(exception);
  }
}

代码示例来源:origin: eu.agrosense.spi/session

public FailurePane() {
  getStyleClass().add("failure");
  setMinWidth(220.0d);
  FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("FailurePane.fxml"));
  fxmlLoader.setRoot(this);
  fxmlLoader.setController(this);
  try {
    fxmlLoader.load();
  } catch (IOException exception) {
    throw new RuntimeException(exception);
  }
}

代码示例来源:origin: eu.agrosense.spi/session

@Override
  public void run() {
    try {
      FXMLLoader loader = new FXMLLoader(getClass().getResource("Login.fxml"));
      loader.setController(controller);
      Parent root = (Parent) loader.load();
      Scene scene = new Scene(root);
      fxPanel.setScene(scene);
    } catch (IOException ex) {
      Exceptions.printStackTrace(ex);
    }
  }
});

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

FXMLLoader loadSynchronously(final URL resource, ResourceBundle bundle, final String conventionalName) throws IllegalStateException {
  final FXMLLoader loader = new FXMLLoader(resource, bundle);
  PresenterFactory factory = discover();
  Callback<Class<?>, Object> controllerFactory = (Class<?> p) -> factory.instantiatePresenter(p, this.injectionContext);
  loader.setControllerFactory(controllerFactory);
  try {
    loader.load();
  } catch (IOException ex) {
    throw new IllegalStateException("Cannot load " + conventionalName, ex);
  }
  return loader;
}

代码示例来源:origin: org.tentackle/tentackle-fx

/**
 * Loads an object hierarchy from a FXML document.<br>
 *
 * @param <T> the object's type
 * @param location the url
 * @return the object
 * @throws IOException if loading failed
 */
public static <T> T load(URL location) throws IOException {
 FXMLLoader loader = new FXMLLoader(location, null, FxFactory.getInstance().getBuilderFactory());
 return loader.load();
}

代码示例来源:origin: org.tentackle/tentackle-fx

/**
 * Loads an object hierarchy from a FXML document.<br>
 *
 * @param <T> the object's type
 * @param location the url
 * @param resources the optional resources
 * @return the object
 * @throws IOException if loading failed
 */
public static <T> T load(URL location, ResourceBundle resources) throws IOException {
 FXMLLoader loader = new FXMLLoader(location, resources, FxFactory.getInstance().getBuilderFactory());
 return loader.load();
}

代码示例来源:origin: org.drombler.fx/drombler-fx-core-commons

/**
 * Loads the &lt;class name&gt;.fxml file, which is expected to be in the same package as the specified type.
 * 
 * @param loader the {@link FXMLLoader}
 * @param type the type
 * @return the loaded object
 * @throws IOException 
 */
public static Object load(FXMLLoader loader, Class<?> type) throws IOException {
  try (InputStream is = getFXMLInputStream(type)) {
    if (is == null) {
      // avoid NullPointerException
      throw new ResourceFileNotFoundException(getAbsoluteFxmlResourcePath(type));
    }
    return loader.load(is);
  }
}

代码示例来源:origin: com.github.wshackle/poseList3DPlot

@Override
public void start(Stage stage) throws Exception {
  FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/Scene.fxml"));
  Parent root = loader.load();
  
  Scene scene = new Scene(root);
  scene.getStylesheets().add("/styles/Styles.css");
  
  stage.setTitle("Pose List 3D Plot");
  stage.setScene(scene);
  FXMLController controller = loader.getController();
  controller.setStage(stage);
  stage.show();
}

相关文章