Example usage for javafx.fxml FXMLLoader FXMLLoader

List of usage examples for javafx.fxml FXMLLoader FXMLLoader

Introduction

In this page you can find the example usage for javafx.fxml FXMLLoader FXMLLoader.

Prototype

public FXMLLoader(Charset charset) 

Source Link

Document

Creates a new FXMLLoader instance.

Usage

From source file:aajavafx.EmployeeController.java

@FXML
private void handleGoBack(ActionEvent event) {
    //labelError.setText(null);
    try {//ww  w. j av a2s  .  c  om
        Node node = (Node) event.getSource();
        Stage stage = (Stage) node.getScene().getWindow();
        FXMLLoader loader = new FXMLLoader(getClass().getResource("MainPageTab.fxml"));
        Parent root = loader.load();
        Scene scene = new Scene(root, 879, 599);
        stage.setScene(scene);

        stage.setTitle("Main menu");
        stage.show();

    } catch (Exception ex) {
        Logger.getLogger(MainPageController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.rvantwisk.cnctools.controllers.TaskEditController.java

public void setTask(final Project project, final TaskRunnable taskRunnable) {
    currentTaskRunnable = taskRunnable;//from   w  w w .ja v a2 s.c  o m
    tasksController = (MillTaskController) applicationContext.getBean(taskRunnable.getClassName());

    // Ensure we supply a non-null model to the operation
    if (taskRunnable.getMilltaskModel() == null) {
        TaskModel m = tasksController.createNewModel();
        taskRunnable.setMilltaskModel(m);
        tasksController.setModel(m);
    } else {
        tasksController.setModel(taskRunnable.getMilltaskModel());
    }
    tasksController.setProject(project);

    // get the resource path of the main class for this MillTask
    List<String> path = new ArrayList<>(Arrays.asList(taskRunnable.getClassName().split("\\.")));
    path.remove(path.size() - 1);

    // verify the fxml location
    final String tpackage = StringUtils.join(path, "/") + "/" + taskRunnable.getFxmlFileName();
    if (tpackage.contains("../") || tpackage.contains("http:") || tpackage.contains("https:")) {
        throw new RuntimeException(
                "Resource for ApplicapableMillTask with name [" + taskRunnable.getName() + "] is invalid.");
    }

    try {
        FXMLLoader loader = new FXMLLoader(
                tasksController.getClass().getResource(taskRunnable.getFxmlFileName()));
        loader.setControllerFactory(new Callback<Class<?>, Object>() {
            @Override
            public Object call(Class<?> aClass) {
                return tasksController;
            }
        });

        lbHeader.setText(taskRunnable.getName());
        AnchorPane aPane = (AnchorPane) loader.load();
        taskPane.getChildren().add(aPane);
        taskPane.setBottomAnchor(aPane, 0.0);
        taskPane.setTopAnchor(aPane, 0.0);
        taskPane.setRightAnchor(aPane, 0.0);
        taskPane.setLeftAnchor(aPane, 0.0);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:spdxedit.externalRef.ExternalRefListControl.java

public AnchorPane getUi() {
    try {/*  w w  w  .j  av  a 2s.c  om*/
        FXMLLoader loader = new FXMLLoader(ExternalRefListControl.class.getResource("/ExternalRefList.fxml"));
        loader.setController(this);
        AnchorPane pane = loader.load();
        return pane;
    } catch (IOException ioe) {
        throw new RuntimeException("Unable to load scene for License editor dialog");
    }
}

From source file:ca.wumbo.doommanager.client.controller.CoreController.java

/**
 * The starting point of the application. The Core should pass the first
 * stage (what should be the primary stage) to this method, which will in
 * turn cascade and create all the //from   w ww.  j ava2s. co m
 * 
 * @param primaryStage
 *       The stage created by the main JavaFX thread at the beginning.
 * 
 * @throws IOException
 *       If there is an error loading the FXML file.
 * 
 * @throws NullPointerException
 *       If the argument is null.
 */
public void start(Stage primaryStage) throws IOException {
    if (primaryStage == null)
        throw new NullPointerException("Passed a null stage to start.");

    // Load the required data into ourselves.
    FXMLLoader loader = new FXMLLoader(Client.class.getResource(fxmlPath));
    loader.setControllerFactory((cls) -> {
        return this;
    });
    loader.load();

    // Add the loaded tab panes into their respective tabs.
    mainTab.setContent(startController.getRootPane());
    fileEditorTab.setContent(fileEditorController.getRootPane());
    mapEditorTab.setContent(mapEditorController.getRootPane());
    textureDatabaseTab.setContent(textureDatabaseController.getRootPane());
    serverBrowserTab.setContent(serverBrowserController.getRootPane());
    ircTab.setContent(ircController.getRootPane());
    optionsTab.setContent(optionsController.getRootPane());
    consoleTab.setContent(consoleController.getRootPane());

    // Set up the scene and stage and display it.
    ClientConfig clientConfig = config.getClientConfig();
    Scene primaryScene = new Scene(rootBorderPane, clientConfig.getStartingWidth(),
            clientConfig.getStartingHeight());
    scene = primaryScene;
    scene.getStylesheets().add(cssPath);
    stage = primaryStage;
    stage.setTitle(applicationTitle + " v" + applicationVersion);
    stage.setMaximized(clientConfig.isStartMaximized());
    stage.setScene(scene);
    stage.show();

    // Start the ticker now that everything is ready to go.
    ticker = new JavaFXTicker((int) (TICRATE_NANO / MS_PER_NANO), event -> tick());
    ticker.start();

    // Set up the network connections by starting the selector.
    if (clientSelector.errorOccured()) {
        Alert alert = new Alert(Alert.AlertType.WARNING, "Unable to request network channels from OS."); // TODO - make less cryptic.
        alert.show();
    } else if (!clientSelector.selectorIsOpen()) {
        Alert alert = new Alert(Alert.AlertType.WARNING, "Unable to open network channels."); // TODO - make less cryptic.
        alert.show();
    }

    // Set up the stage exit handling.
    stage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, event -> ticker.stop());

    log.info("Welcome to " + applicationTitle + " v" + applicationVersion + "!");
}

From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java

@FXML
void onOpen(ActionEvent event) {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Open Metabolome Analysis File");
    fileChooser.getExtensionFilters()//from  ww  w.j a va  2  s .  c o m
            .addAll(new FileChooser.ExtensionFilter("Supported Files", Arrays.asList("*.zip", "*.csv")));
    File file = fileChooser.showOpenDialog(stage);
    if (file == null)
        return;
    if (!opened) {
        openData(file);
    } else {
        try {
            Stage primaryStage = new Stage();
            FXMLLoader loader = new FXMLLoader(getClass().getResource("mainwindow.fxml"));
            loader.load();
            MainWindowController controller = loader.getController();
            controller.setStage(primaryStage);
            VBox root = loader.getRoot();
            Scene scene = new Scene(root);
            primaryStage.setScene(scene);
            controller.openData(file);
            primaryStage.show();
        } catch (IOException e) {
            e.printStackTrace();
            AlertHelper.showExceptionAlert("Cannot open", null, e);
        }
    }
}

From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginViewController.java

protected static ViewCoordinatePreferencesPluginViewController construct() throws IOException {
    // Load from FXML.
    URL resource = ViewCoordinatePreferencesPluginViewController.class
            .getResource("ViewCoordinatePreferencesPluginView.fxml");
    log.debug("Loaded URL {}", resource);
    FXMLLoader loader = new FXMLLoader(resource);
    loader.load();/*from   w w w . ja  v a 2  s . c o  m*/
    return loader.getController();
}

From source file:aajavafx.Schedule1Controller.java

@FXML
private void handleGetCustomersUnvisited(ActionEvent event) throws IOException {
    try {/*from   w ww.  j  ava 2 s. c  o m*/
        getUnsignedCustomers();
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("UnsignedCustomers.fxml"));
        Parent root1 = (Parent) fxmlLoader.load();
        Stage stage = new Stage();
        stage.setScene(new Scene(root1));
        stage.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:analyzer.code.FXMLAnalyzerController.java

@FXML
private void metricsCplusPlusMunuItem() throws FileNotFoundException, IOException {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("FXMLMetrics.fxml"));
    try {/*  w  w w . j a va 2s.  c  om*/
        AnchorPane pane = (AnchorPane) loader.load();
        fxmlmc = loader.getController();
        fxmlmc.setAnalyzer((AnalyzerC) analyzer);
        Scene scene = new Scene(pane);
        Stage stage = new Stage();
        stage.setScene(scene);
        stage.setTitle(" ++");
        stage.show();
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:org.sleuthkit.autopsy.imagegallery.gui.MetaDataPane.java

public MetaDataPane(ImageGalleryController controller) {
    this.controller = controller;

    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MetaDataPane.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

    try {/*from  www .j  a  v  a  2s  . c  o m*/
        fxmlLoader.load();
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }
}

From source file:aajavafx.VisitorScheduleController.java

@FXML
private void handleBackButton(ActionEvent event) {
    try {//from w  ww  .  j  a  v a  2 s  .c  o m
        Node node = (Node) event.getSource();
        Stage stage = (Stage) node.getScene().getWindow();
        FXMLLoader loader = new FXMLLoader(getClass().getResource("MainPage.fxml"));
        Parent root = loader.load();
        Scene scene = new Scene(root, 879, 599);
        stage.setScene(scene);

        stage.setTitle("Main menu");
        stage.show();

    } catch (Exception ex) {
        Logger.getLogger(MainPageController.class.getName()).log(Level.SEVERE, null, ex);
    }
}