Search in sources :

Example 81 with FXMLLoader

use of javafx.fxml.FXMLLoader in project trex-stateless-gui by cisco-system-traffic-generator.

the class TrexApp method start.

@Override
public void start(Stage stage) throws Exception {
    speedupTooltip();
    primaryStage = stage;
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/MainView.fxml"));
    AnchorPane page = fxmlLoader.load();
    MainViewController mainviewcontroller = fxmlLoader.getController();
    Scene scene = new Scene(page);
    scene.getStylesheets().add(TrexApp.class.getResource("/styles/mainStyle.css").toExternalForm());
    stage.setScene(scene);
    stage.setTitle("TRex");
    stage.setResizable(true);
    stage.setMinWidth(780);
    stage.setMinHeight(700);
    stage.getIcons().add(new Image("/icons/trex.png"));
    packetBuilderAppController = injector.getInstance(AppController.class);
    PreferencesManager.getInstance().setPacketEditorConfigurations(packetBuilderAppController.getConfigurations());
    packetBuilderAppController.registerEventBusHandler(mainviewcontroller);
    stage.show();
}
Also used : MainViewController(com.exalttech.trex.ui.controllers.MainViewController) AppController(com.xored.javafx.packeteditor.controllers.AppController) Scene(javafx.scene.Scene) Image(javafx.scene.image.Image) FXMLLoader(javafx.fxml.FXMLLoader) AnchorPane(javafx.scene.layout.AnchorPane)

Example 82 with FXMLLoader

use of javafx.fxml.FXMLLoader in project trex-stateless-gui by cisco-system-traffic-generator.

the class ImportedPacketPropertiesView method loadFXML.

/**
     * Load Fxml UI implementation
     */
private void loadFXML() {
    try {
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/ImportedPacketPropertiesView.fxml"));
        fxmlLoader.setRoot(this);
        fxmlLoader.setController(this);
        fxmlLoader.load();
    } catch (Exception ex) {
        LOG.error("Error setting UI", ex);
    }
}
Also used : FXMLLoader(javafx.fxml.FXMLLoader)

Example 83 with FXMLLoader

use of javafx.fxml.FXMLLoader in project jgnash by ccavanaugh.

the class JasperViewerDialogController method loadReportController.

public <T extends DynamicJasperReport> T loadReportController(final String fxmlResource) {
    try {
        final FXMLLoader fxmlLoader = new FXMLLoader(PortfolioReportController.class.getResource(fxmlResource), resources);
        reportControllerPaneProperty.setValue(fxmlLoader.load());
        T controller = fxmlLoader.getController();
        report.setValue(controller);
        return controller;
    } catch (IOException e) {
        StaticUIMethods.displayException(e);
        return null;
    }
}
Also used : PortfolioReportController(jgnash.uifx.report.PortfolioReportController) IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader)

Example 84 with FXMLLoader

use of javafx.fxml.FXMLLoader in project jgnash by ccavanaugh.

the class FXMLUtils method loadFXML.

/**
     * Creates a new Stage with application defaults {@code StageStyle.DECORATED}, {@code Modality.APPLICATION_MODAL}
     * with the specified fxml file as the {@code Scene}.
     *
     * @param controller     controller object to pass to the {@code FXMLLoader}
     * @param fileName       name of the fxml file.  It's assumed to be in the same package as the controller
     * @param resourceBundle {@code ResourceBundle} to pass to the {@code FXMLLoader}
     * @return new {@code Stage}
     */
public static Stage loadFXML(final Object controller, final String fileName, final ResourceBundle resourceBundle) {
    final URL fxmlUrl = controller.getClass().getResource(fileName);
    final FXMLLoader fxmlLoader = new FXMLLoader(fxmlUrl, resourceBundle);
    final Stage stage = new Stage(StageStyle.DECORATED);
    stage.initModality(Modality.APPLICATION_MODAL);
    if (MainView.getInstance() != null) {
        // null check is only necessary to pass unit tests
        stage.initOwner(MainView.getPrimaryStage());
    }
    try {
        fxmlLoader.setController(controller);
        final Scene scene = new Scene(fxmlLoader.load());
        scene.getStylesheets().addAll(MainView.DEFAULT_CSS);
        scene.getRoot().styleProperty().bind(ThemeManager.styleProperty());
        stage.setScene(scene);
        stage.getIcons().add(StaticUIMethods.getApplicationIcon());
        // force a resize, some stages need a push
        stage.sizeToScene();
        // Inject the scene into the controller
        injectParent(controller, scene);
    } catch (final IOException ioe) {
        // log and throw an unchecked exception
        Logger.getLogger(FXMLUtils.class.getName()).log(Level.SEVERE, ioe.getMessage(), ioe);
        throw new UncheckedIOException(ioe);
    }
    return stage;
}
Also used : Stage(javafx.stage.Stage) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) URL(java.net.URL)

Example 85 with FXMLLoader

use of javafx.fxml.FXMLLoader in project jgnash by ccavanaugh.

the class FXMLUtils method loadFXML.

/**
     * Reduces boilerplate code to load a fxml file.
     *
     * @param consumer       {@code Consumer to pass to the parent node},
     * @param fileName       name of the fxml file.  It's assumed to be in the same package as the consumer
     * @param resourceBundle {@code ResourceBundle} to pass to the {@code FXMLLoader}
     * @param <R>            must extend {@code Node}
     * @param <C>            the fxml controller
     * @return the controller for the fxml file
     */
public static <R extends Node, C> C loadFXML(@NotNull final Consumer<R> consumer, @NotNull final String fileName, @NotNull final ResourceBundle resourceBundle) {
    final URL fxmlUrl = consumer.getClass().getResource(fileName);
    final FXMLLoader fxmlLoader = new FXMLLoader(fxmlUrl, resourceBundle);
    try {
        R root = fxmlLoader.load();
        C controller = fxmlLoader.getController();
        consumer.accept(root);
        root.styleProperty().bind(ThemeManager.styleProperty());
        // Inject the root into the controller
        injectParent(controller, root);
        return controller;
    } catch (final IOException ioe) {
        // log and throw an unchecked exception
        Logger.getLogger(FXMLUtils.class.getName()).log(Level.SEVERE, ioe.getMessage(), ioe);
        throw new UncheckedIOException(ioe);
    }
}
Also used : UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) FXMLLoader(javafx.fxml.FXMLLoader) URL(java.net.URL)

Aggregations

FXMLLoader (javafx.fxml.FXMLLoader)86 IOException (java.io.IOException)46 Scene (javafx.scene.Scene)30 Stage (javafx.stage.Stage)20 Parent (javafx.scene.Parent)19 BorderPane (javafx.scene.layout.BorderPane)16 Pane (javafx.scene.layout.Pane)13 StackPane (javafx.scene.layout.StackPane)13 URL (java.net.URL)12 FXML (javafx.fxml.FXML)10 ActionEvent (javafx.event.ActionEvent)8 List (java.util.List)7 File (java.io.File)6 Properties (java.util.Properties)6 ObservableList (javafx.collections.ObservableList)5 Node (javafx.scene.Node)5 JavaSVNManager (com.kyj.scm.manager.svn.java.JavaSVNManager)4 UncheckedIOException (java.io.UncheckedIOException)4 TextField (javafx.scene.control.TextField)4 MouseEvent (javafx.scene.input.MouseEvent)4