Java Code Examples for javafx.fxml.FXMLLoader#setResources()

The following examples show how to use javafx.fxml.FXMLLoader#setResources() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FullImageView.java    From neural-style-gui with GNU General Public License v3.0 6 votes vote down vote up
public FullImageView(File imageFile, Consumer<ActionEvent> styleEvent, Consumer<ActionEvent> contentEvent, Consumer<ActionEvent> initEvent, ResourceBundle resources) {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/imagePreviewTab.fxml"));
    fxmlLoader.setResources(resources);
    fxmlLoader.setController(this);
    fxmlLoader.setRoot(this);

    try {
        fxmlLoader.load();
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }

    image.fitWidthProperty().bind(widthProperty());
    image.fitHeightProperty().bind(heightProperty());

    imageView = new MovingImageView(image);
    imageView.setImage(imageFile);

    EventStreams.eventsOf(style, ActionEvent.ACTION)
            .subscribe(styleEvent);
    EventStreams.eventsOf(content, ActionEvent.ACTION)
            .subscribe(contentEvent);
    EventStreams.eventsOf(init, ActionEvent.ACTION)
            .subscribe(initEvent);
}
 
Example 2
Source File: OfflineAdminApp.java    From chvote-1-0 with GNU Affero General Public License v3.0 5 votes vote down vote up
private BorderPane initRootLayout(ResourceBundle bundle) throws IOException {
    FXMLLoader loader = new FXMLLoader();
    URL resource = this.getClass().getResource("/ch/ge/ve/offlineadmin/view/RootLayout.fxml");
    loader.setLocation(resource);
    loader.setResources(bundle);

    return loader.load();
}
 
Example 3
Source File: CurlyApp.java    From curly with Apache License 2.0 5 votes vote down vote up
public static Action editAction(Action source, Runnable persistHandler) {
    final BooleanProperty okPressed = new SimpleBooleanProperty(false);
    if (source == null) {
        source = new Action();
    }

    try {
        FXMLLoader loader = new FXMLLoader(CurlyApp.class.getResource("/fxml/ActionPanel.fxml"));
        loader.setResources(ApplicationState.getInstance().getResourceBundle());
        loader.load();
        ActionPanelController actionController = loader.getController();

        Stage popup = new Stage();
        popup.setScene(new Scene(loader.getRoot()));
        popup.initModality(Modality.APPLICATION_MODAL);
        popup.initOwner(applicationWindow);

        actionController.populateValues(source, true);
        actionController.onPersist(() -> {
            if (persistHandler != null) {
                persistHandler.run();
            }
            okPressed.set(true);
        });
        actionController.whenFinished(popup::close);

        popup.showAndWait();
    } catch (IOException ex) {
        Logger.getLogger(CurlyApp.class.getName()).log(Level.SEVERE, null, ex);
    }
    if (okPressed.get()) {
        return source;
    } else {
        return null;
    }
}
 
Example 4
Source File: FxmlHandler.java    From VocabHunter with Apache License 2.0 5 votes vote down vote up
private <T> T loadNode(final FXMLLoader loader, final ViewFxml fxml) {
    String name = fxml.getName();

    try {

        loader.setLocation(getClass().getResource("/" + name));
        loader.setResources(i18nManager.bundle());

        return loader.load();
    } catch (final IOException e) {
        throw new VocabHunterException(String.format("Unable to load FXML '%s'", name), e);
    }
}
 
Example 5
Source File: FxmlUtil.java    From Augendiagnose with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Utility method to expand an FXML file for a custom component.
 *
 * @param root
 *            The custom component.
 * @param fxmlFile
 *            The FXML file.
 */
public static void loadFromFxml(final Parent root, final String fxmlFile) {
	FXMLLoader fxmlLoader = new FXMLLoader(ClassLoader.getSystemResource("fxml/" + fxmlFile));
	fxmlLoader.setResources(ResourceUtil.STRINGS_BUNDLE);
	fxmlLoader.setController(root);
	fxmlLoader.setRoot(root);
	try {
		fxmlLoader.load();
		root.getStylesheets().add(ClassLoader.getSystemResource("css/application.css").toExternalForm());
	}
	catch (IOException e) {
		Logger.error("Failed to load FXML file " + fxmlFile, e);
		throw new RuntimeException(e);
	}
}
 
Example 6
Source File: FXMLLoaderFactory.java    From OEE-Designer with MIT License 5 votes vote down vote up
public static FXMLLoader templateScheduleLoader() throws Exception {
	FXMLLoader fxmlLoader = new FXMLLoader(
			TemplateScheduleDialogController.class.getResource("TemplateScheduleDialog.fxml"));
	fxmlLoader.setResources(getDesignerLangBundle());
	fxmlLoader.load();
	return fxmlLoader;
}
 
Example 7
Source File: FxmlManager.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Simplified way to load a Node & Controller.
 *
 * @return A LoadedNode object
 */
public <C, N> LoadedNode<C, N> load() {
  try {
    final FXMLLoader loader = new FXMLLoader(getClass().getResource(value));
    // TODO load locale based on user setting
    loader.setResources(ResourceBundle.getBundle(LANG_CLASS_BASENAME, new Locale("en", "US")));
    loader.load();
    return new LoadedNode<>(loader.getController(), loader.getRoot());
  } catch (final IOException e) {
    throw new IllegalStateException("Failed to load FXML " + value, e);
  }
}
 
Example 8
Source File: FXMLLoaderFactory.java    From OEE-Designer with MIT License 4 votes vote down vote up
public static FXMLLoader jmsTrendLoader() throws Exception {
	FXMLLoader fxmlLoader = new FXMLLoader(JmsTrendController.class.getResource("JMSTrend.fxml"));
	fxmlLoader.setResources(getDesignerLangBundle());
	fxmlLoader.load();
	return fxmlLoader;
}
 
Example 9
Source File: FXMLLoaderFactory.java    From OEE-Designer with MIT License 4 votes vote down vote up
public static FXMLLoader trendChartLoader() throws Exception {
	FXMLLoader fxmlLoader = new FXMLLoader(TrendChartController.class.getResource("TrendChart.fxml"));
	fxmlLoader.setResources(getDesignerLangBundle());
	fxmlLoader.load();
	return fxmlLoader;
}
 
Example 10
Source File: FXMLLoaderFactory.java    From OEE-Designer with MIT License 4 votes vote down vote up
public static FXMLLoader cronTrendLoader() throws Exception {
	FXMLLoader fxmlLoader = new FXMLLoader(CronTrendController.class.getResource("CronTrend.fxml"));
	fxmlLoader.setResources(getDesignerLangBundle());
	fxmlLoader.load();
	return fxmlLoader;
}
 
Example 11
Source File: FXMLLoaderFactory.java    From OEE-Designer with MIT License 4 votes vote down vote up
public static FXMLLoader cronEditorLoader() throws Exception {
	FXMLLoader fxmlLoader = new FXMLLoader(CronEditorController.class.getResource("CronEditor.fxml"));
	fxmlLoader.setResources(getDesignerLangBundle());
	fxmlLoader.load();
	return fxmlLoader;
}
 
Example 12
Source File: FXMLLoaderFactory.java    From OEE-Designer with MIT License 4 votes vote down vote up
public static FXMLLoader fileShareLoader() throws Exception {
	FXMLLoader fxmlLoader = new FXMLLoader(FileShareController.class.getResource("FileShare.fxml"));
	fxmlLoader.setResources(getDesignerLangBundle());
	fxmlLoader.load();
	return fxmlLoader;
}
 
Example 13
Source File: FXMLLoaderFactory.java    From OEE-Designer with MIT License 4 votes vote down vote up
public static FXMLLoader databaseServerLoader() throws Exception {
	FXMLLoader fxmlLoader = new FXMLLoader(DatabaseServerController.class.getResource("DatabaseServer.fxml"));
	fxmlLoader.setResources(getDesignerLangBundle());
	fxmlLoader.load();
	return fxmlLoader;
}
 
Example 14
Source File: FXMLLoaderFactory.java    From OEE-Designer with MIT License 4 votes vote down vote up
public static FXMLLoader splashLoader() throws Exception {
	FXMLLoader fxmlLoader = new FXMLLoader(SplashController.class.getResource("Splash.fxml"));
	fxmlLoader.setResources(getDesignerLangBundle());
	fxmlLoader.load();
	return fxmlLoader;
}
 
Example 15
Source File: FXMLLoaderFactory.java    From OEE-Designer with MIT License 4 votes vote down vote up
public static FXMLLoader oeeEventTrendLoader() throws Exception {
	FXMLLoader fxmlLoader = new FXMLLoader(OeeEventTrendController.class.getResource("OeeEventTrend.fxml"));
	fxmlLoader.setResources(getDesignerLangBundle());
	fxmlLoader.load();
	return fxmlLoader;
}
 
Example 16
Source File: FXMLLoaderFactory.java    From OEE-Designer with MIT License 4 votes vote down vote up
public static FXMLLoader fileTrendLoader() throws Exception {
	FXMLLoader fxmlLoader = new FXMLLoader(FileTrendController.class.getResource("FileTrend.fxml"));
	fxmlLoader.setResources(getDesignerLangBundle());
	fxmlLoader.load();
	return fxmlLoader;
}
 
Example 17
Source File: FXMLLoaderFactory.java    From OEE-Designer with MIT License 4 votes vote down vote up
public static FXMLLoader collectorApplicationLoader() throws Exception {
	FXMLLoader fxmlLoader = new FXMLLoader(CollectorApplication.class.getResource("CollectorApplication.fxml"));
	fxmlLoader.setResources(getCollectorLangBundle());
	fxmlLoader.load();
	return fxmlLoader;
}
 
Example 18
Source File: FXMLLoaderFactory.java    From OEE-Designer with MIT License 4 votes vote down vote up
public static FXMLLoader reasonEditorLoader() throws Exception {
	FXMLLoader fxmlLoader = new FXMLLoader(ReasonEditorController.class.getResource("ReasonEditor.fxml"));
	fxmlLoader.setResources(getDesignerLangBundle());
	fxmlLoader.load();
	return fxmlLoader;
}
 
Example 19
Source File: FXMLLoaderFactory.java    From OEE-Designer with MIT License 4 votes vote down vote up
public static FXMLLoader mqttTrendLoader() throws Exception {
	FXMLLoader fxmlLoader = new FXMLLoader(MqttTrendController.class.getResource("MQTTTrend.fxml"));
	fxmlLoader.setResources(getDesignerLangBundle());
	fxmlLoader.load();
	return fxmlLoader;
}
 
Example 20
Source File: FXMLLoaderFactory.java    From OEE-Designer with MIT License 4 votes vote down vote up
public static FXMLLoader modbusTrendLoader() throws Exception {
	FXMLLoader fxmlLoader = new FXMLLoader(ModbusTrendController.class.getResource("ModbusTrend.fxml"));
	fxmlLoader.setResources(getDesignerLangBundle());
	fxmlLoader.load();
	return fxmlLoader;
}