本文整理了Java中javafx.fxml.FXMLLoader.setControllerFactory()
方法的一些代码示例,展示了FXMLLoader.setControllerFactory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FXMLLoader.setControllerFactory()
方法的具体详情如下:
包路径:javafx.fxml.FXMLLoader
类名称:FXMLLoader
方法名:setControllerFactory
暂无
代码示例来源:origin: speedment/speedment
public FXMLLoader fxmlLoader() {
final FXMLLoader loader = new FXMLLoader(StandardCharsets.UTF_8);
loader.setControllerFactory(clazz -> MapStream.of(constructors)
.filterKey(clazz::isAssignableFrom)
.values()
.findFirst()
.map(Supplier::get)
.map(injector::inject)
.orElseThrow(() -> new SpeedmentToolException(
"FXML Controller '" + clazz.getName() +
"' have not been installed in " +
getClass().getSimpleName() + "."
)));
return loader;
}
代码示例来源:origin: speedment/speedment
loader.setControllerFactory(clazz -> {
ref.set(new NotificationController(message, icon, palette, onClose));
return ref.get();
代码示例来源:origin: pmd/pmd
fxmlLoader.setControllerFactory(type -> {
if (type == AuxclasspathSetupController.class) {
return this;
代码示例来源:origin: pmd/pmd
SourceEditorController sourceEditorController = new SourceEditorController(owner, mainController);
loader.setControllerFactory(type -> {
if (type == MainDesignerController.class) {
return mainController;
代码示例来源:origin: de.roskenet/springboot-javafx-support
/**
* Load synchronously.
*
* @param resource
* the resource
* @param bundle
* the bundle
* @return the FXML loader
* @throws IllegalStateException
* the illegal state exception
*/
private FXMLLoader loadSynchronously(final URL resource, final Optional<ResourceBundle> bundle) throws IllegalStateException {
final FXMLLoader loader = new FXMLLoader(resource, bundle.orElse(null));
loader.setControllerFactory(this::createControllerForType);
try {
loader.load();
} catch (final IOException | IllegalStateException e) {
throw new IllegalStateException("Cannot load " + getConventionalName(), e);
}
return loader;
}
代码示例来源:origin: com.airhacks/afterburner.fx
FXMLLoader loadSynchronously(final URL resource, ResourceBundle bundle, final String conventionalName) throws IllegalStateException {
final FXMLLoader loader = new FXMLLoader(resource, bundle);
PresenterFactory factory = discover();
Callback<Class<?>, Object> controllerFactory = (Class<?> p) -> factory.instantiatePresenter(p, this.injectionContext);
loader.setControllerFactory(controllerFactory);
try {
loader.load();
} catch (IOException ex) {
throw new IllegalStateException("Cannot load " + conventionalName, ex);
}
return loader;
}
代码示例来源:origin: io.datafx/flow
private FXMLLoader createLoader(final Object controller, String fxmlName, ViewConfiguration viewConfiguration)
throws FxmlLoadException {
Class<?> controllerClass = controller.getClass();
String foundFxmlName = getFxmlName(controllerClass);
if (fxmlName != null) {
foundFxmlName = fxmlName;
}
if (foundFxmlName == null) {
throw new FxmlLoadException("No FXML File specified!");
}
FXMLLoader fxmlLoader = new FXMLLoader(
controllerClass.getResource(foundFxmlName));
fxmlLoader.setBuilderFactory(viewConfiguration.getBuilderFactory());
fxmlLoader.setCharset(viewConfiguration.getCharset());
fxmlLoader.setResources(viewConfiguration.getResources());
fxmlLoader.setController(controller);
fxmlLoader.setControllerFactory(c -> controller);
return fxmlLoader;
}
代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.osgi.util
loader.setControllerFactory(controllerFactory);
代码示例来源:origin: org.javafxdata/datafx-controller
private FXMLLoader createLoader(final Object controller, String fxmlName, ViewConfiguration viewConfiguration)
throws FxmlLoadException {
Class<?> controllerClass = controller.getClass();
String foundFxmlName = getFxmlName(controllerClass);
if (fxmlName != null) {
foundFxmlName = fxmlName;
}
if (foundFxmlName == null) {
throw new FxmlLoadException("No FXML File specified!");
}
FXMLLoader fxmlLoader = new FXMLLoader(
controllerClass.getResource(foundFxmlName));
fxmlLoader.setBuilderFactory(viewConfiguration.getBuilderFactory());
fxmlLoader.setCharset(viewConfiguration.getCharset());
fxmlLoader.setResources(viewConfiguration.getResources());
fxmlLoader.setController(controller);
fxmlLoader.setControllerFactory(new Callback<Class<?>, Object>() {
@Override
public Object call(Class<?> arg0) {
return controller;
}
});
return fxmlLoader;
}
代码示例来源:origin: org.codehaus.griffon/griffon-javafx
protected void configureFxmlLoader(@Nonnull FXMLLoader fxmlLoader) {
fxmlLoader.setBuilderFactory(new GriffonBuilderFactory(getApplication(), getMvcGroup()));
fxmlLoader.setResources(getApplication().getMessageSource().asResourceBundle());
fxmlLoader.setClassLoader(getApplication().getApplicationClassLoader().get());
fxmlLoader.setControllerFactory(klass -> getMvcGroup().getView());
}
代码示例来源:origin: com.cathive.fx/fx-guice
loader.setControllerFactory(new Callback<Class<?>, Object>() {
@Override
public Object call(final Class<?> param) {
代码示例来源:origin: org.jrebirth.af/core
fxmlLoader.setControllerFactory(fxmlControllerFactory);
内容来源于网络,如有侵权,请联系作者删除!