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

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

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

FXMLLoader.getController介绍

暂无

代码示例

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

void initializeFXMLLoader() {
  if (this.fxmlLoader == null) {
    this.fxmlLoader = this.loadSynchronously(resource, bundle, bundleName);
    this.presenterProperty.set(this.fxmlLoader.getController());
  }
}

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

/**
 * Ensure fxml loader initialized.
 */
private void ensureFxmlLoaderInitialized() {
  if (fxmlLoader != null) {
    return;
  }
  fxmlLoader = loadSynchronously(resource, bundle);
  presenterProperty.set(fxmlLoader.getController());
}

代码示例来源: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();
}

代码示例来源:origin: it.unibo.alchemist/alchemist-projectview

/**
 * 
 */
@FXML
public void clickNext() {
  final FXMLLoader loader = new FXMLLoader();
  loader.setLocation(ProjectGUI.class.getResource("view/NewProjLayoutSelect.fxml"));
  try {
    final AnchorPane pane = (AnchorPane) loader.load();
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    final double width = screenSize.getWidth() * 20.83 / 100;
    final double height = screenSize.getHeight() * 13.89 / 100;
    final Scene scene = new Scene(pane, width, height);
    this.stage.setScene(scene);
    final NewProjLayoutSelectController ctrl = loader.getController();
    ctrl.setFolderPath(this.path);
    ctrl.setMain(this.main);
    ctrl.setStage(this.stage);
  } catch (IOException e) {
    L.error("Error loading the graphical interface. This is most likely a bug.", e);
    System.exit(1);
  }
}

代码示例来源:origin: it.unibo.alchemist/alchemist-projectview

if (layoutName.equals("TopLayout")) {
  this.root.setTop(pane);
  this.controllerTop = loader.getController();
  this.controllerTop.setMain(this);
  this.controllerTop.setCtrlLeft(this.controllerLeft);
} else if (layoutName.equals("LeftLayout")) {
  this.root.setLeft(pane);
  this.controllerLeft = loader.getController();
  this.controllerLeft.setMain(this);
} else {
  this.root.setCenter(pane);
  this.controllerCenter = loader.getController();
  this.controllerCenter.setMain(this);
  this.controllerCenter.setCtrlLeft(this.controllerLeft);

代码示例来源:origin: eu.agrosense.client/grid-api

public void run() {
//                Parent root;
        try {
//                    root = FXMLLoader.load(getClass().getResource("/eu/agrosense/client/grid/impl/GridPropertiesElement.fxml"));
//                    Scene scene = new Scene(root);
//                    fxPanel.setScene(scene);

          String fxml = "GridPropertiesElement.fxml";
          FXMLLoader loader = new FXMLLoader();
          InputStream in = GridPropertiesElement.class.getResourceAsStream(fxml);
          loader.setBuilderFactory(new JavaFXBuilderFactory());
          loader.setLocation(GridPropertiesElement.class.getResource(fxml));
          AnchorPane page;
          try {
            page = (AnchorPane) loader.load(in);
          } finally {
            in.close();
          }
          Scene scene = new Scene(page, 800, 600);
          fxPanel.setScene(scene);
          controller = loader.getController();
          controller.setGrid(gridDataObject.getLookup().lookup(Grid.class));
        } catch (IOException ex) {
          Exceptions.printStackTrace(ex);
        }
      }
    });

代码示例来源:origin: it.unibo.alchemist/alchemist-projectview

private void newFile(final String extension) {
  try {
    final FXMLLoader loader = new FXMLLoader();
    loader.setLocation(ProjectGUI.class.getResource("view/FileNameDialog.fxml"));
    final AnchorPane pane = (AnchorPane) loader.load();
    final Stage stage = new Stage();
    stage.setTitle(RESOURCES.getString("file_name_title"));
    stage.initModality(Modality.WINDOW_MODAL);
    stage.initOwner(this.main.getStage());
    stage.setResizable(false);
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    final double width = screenSize.getWidth() * 20.83 / 100;
    final double height = screenSize.getHeight() * 13.89 / 100;
    final Scene scene = new Scene(pane, width, height);
    stage.setScene(scene);
    final FileNameDialogController controller = loader.getController();
    controller.setDialogStage(stage);
    controller.setExtension(extension);
    controller.setCtrlLeftLayout(this.ctrlLeft);
    stage.showAndWait();
  } catch (IOException e) {
    L.error("Error loading the graphical interface. This is most likely a bug.", e);
    System.exit(1);
  }
}

代码示例来源:origin: it.unibo.alchemist/alchemist-projectview

private void loadLayout(final boolean isFolder) {
  final FXMLLoader loader = new FXMLLoader();
  loader.setLocation(ProjectGUI.class.getResource("view/NewFolderOrFileDialog.fxml"));
  AnchorPane pane;
  try {
    pane = (AnchorPane) loader.load();
  } catch (IOException e) {
    throw new IllegalStateException(e);
  }
  final Stage stage = new Stage();
  if (isFolder) {
    stage.setTitle(RESOURCES.getString("folder_name_title"));
  } else {
    stage.setTitle(RESOURCES.getString("file_name_title"));
  }
  stage.initModality(Modality.WINDOW_MODAL);
  stage.initOwner(this.main.getStage());
  stage.setResizable(false);
  final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  final double width = screenSize.getWidth() * 20.83 / 100;
  final double height = screenSize.getHeight() * 13.89 / 100;
  final Scene scene = new Scene(pane, width, height);
  stage.setScene(scene);
  final NewFolderOrFileDialogController controller = loader.getController();
  controller.initialize(isFolder);
  controller.setSelectedItem(this.selectedFile);
  controller.setStage(stage);
  stage.showAndWait();
}

代码示例来源:origin: com.bitplan.gui/com.bitplan.javafx

/**
 * load me from the given fxml fileName
 * 
 * @param fxmlFileName
 * @return the load Result
 */
public <T> LoadResult<T> load(String fxmlFileName) {
 try {
  LoadResult<T> loadResult = new LoadResult<T>();
  ResourceBundle resourceBundle = Translator.getBundle();
  URL fxml = JFXWizardPane.class
    .getResource(resourcePath + fxmlFileName + ".fxml");
  FXMLLoader fxmlLoader = new FXMLLoader(fxml, resourceBundle);
  loadResult.parent = fxmlLoader.load();
  loadResult.setController(fxmlLoader.getController());
  return loadResult;
 } catch (Throwable th) {
  ErrorHandler.handle(th);
 }
 return null;
}

代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.osgi.util

O value = loader.load(stream);
if (value != null) {
  return new FXMLData<O, C>(value, (C) loader.getController());
  O value = loader.load(in);
  if (value != null) {
    return new FXMLData<O, C>(value, (C) loader.getController());

代码示例来源:origin: brunoborges/webfx

public void openNetworkSettings() {
  final FXMLLoader settings = FXUtil.load(SettingsController.class);
  try {
    final Node node = settings.load();
    final SettingsController controller = settings.getController();
    final Stage stage = new Stage();
    final Scene scene = new Scene(new Group(node));
    stage.setTitle("Network Settings");
    stage.setScene(scene);
    stage.initModality(Modality.APPLICATION_MODAL);
    controller.setOnClose(e -> stage.close());
    stage.show();
  } catch (IOException ex) {
    Logger.getLogger(BrowserFXController.class.getName()).log(Level.SEVERE, "Unable to open settings", ex);
  }
}

代码示例来源:origin: it.unibo.alchemist/alchemist-projectview

/**
 * @throws IOException
 *             if the XML can not get loaded
 */
@FXML
public void clickBack() throws IOException {
  final FXMLLoader loader = new FXMLLoader();
  loader.setLocation(ProjectGUI.class.getResource("view/NewProjLayoutFolder.fxml"));
  final AnchorPane pane = (AnchorPane) loader.load();
  final Scene scene = new Scene(pane);
  this.stage.setScene(scene);
  final NewProjLayoutFolderController ctrl = loader.getController();
  ctrl.setMain(this.main);
  ctrl.setStage(this.stage);
  ctrl.setFolderPath(this.folderPath);
}

代码示例来源:origin: it.unibo.alchemist/alchemist-projectview

final Scene scene = new Scene(pane, width, height);
stage.setScene(scene);
final NewProjLayoutFolderController ctrl = loader.getController();
ctrl.setMain(this.main);
ctrl.setStage(stage);

代码示例来源:origin: sc.fiji/OMEVisual

public void initFX(JFXPanel fxPanel) {
  // Init the root layout
  try {
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(MainAppFrame.class.getResource("/sc/fiji/omevisual/gui/view/RootLayout.fxml"));
    AnchorPane rootLayout = (AnchorPane) loader.load();
    // Get the controller and add an ImageJ context to it.
    RootLayoutController controller = loader.getController();
    controller.setContext(ij.context());
    controller.setImage(this.image);
    // Show the scene containing the root layout.
    Scene scene = new Scene(rootLayout);
    this.fxPanel.setScene(scene);
    // Resize the JFrame to the JavaFX scene
    this.setSize((int) scene.getWidth(), (int) scene.getHeight());
    controller.fill(md);
  } catch (IOException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: org.jrebirth.af/core

final FXMLController<M, ?> fxmlController = (FXMLController<M, ?>) fxmlLoader.getController();
  if (!error && !(fxmlLoader.getController() instanceof AbstractFXMLController)) {
    throw new CoreRuntimeException(BAD_FXML_CONTROLLER_ANCESTOR.getText(fxmlLoader.getController().getClass().getCanonicalName()));

代码示例来源:origin: brunoborges/webfx

@Override
public void start(Stage stage) throws Exception {
  FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("browser.fxml"));
  Parent root = (Parent) fxmlLoader.load();
  stage.getIcons().addAll(
      new Image("/webfx/browser/icons/globe_16.png", 16, 16, true, true),
      new Image("webfx/browser/icons/globe_32.png", 32, 32, true, true),
      new Image("webfx/browser/icons/globe_64.png", 64, 64, true, true)
  );
  BrowserFXController controller = fxmlLoader.getController();
  controller.setLocale(getCurrentLocale());
  Scene scene = new Scene(root);
  BrowserShortcuts shortcuts = new BrowserShortcuts(scene);
  shortcuts.setup(controller);
  stage.setTitle("WebFX Browser");
  stage.setScene(scene);
  stage.show();
}

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

controller = loader.getController();
controller.setView(view);
if (view instanceof FxContainer) {

代码示例来源:origin: com.cathive.fx/fx-guice

result.location.set(loader.getLocation());
result.resources.set(loader.getResources());
result.controller.set(loader.getController());
result.root.set(root);
result.charset.set(loader.getCharset());

相关文章