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();
}
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);
}
}
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;
}
}
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;
}
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);
}
}
Aggregations