use of javafx.fxml.JavaFXBuilderFactory in project Gargoyle by callakrsos.
the class FXMLPreviewLoader method start.
/**
* @inheritDoc
*/
@Override
public void start(Stage primaryStage) throws Exception {
BorderPane borderPane = new BorderPane();
FXMLLoader loader = new FXMLLoader() {
};
// InputStream resourceAsStream =
// FXMLPreviewLoader.class.getResourceAsStream("lang_ko.properties");
//
// loader.setResources(new PropertyResourceBundle(new
// InputStreamReader(resourceAsStream, "UTF-8")) {
// /*
// * @inheritDoc
// */
// @Override
// public boolean containsKey(String key) {
// return true;
// }
//
// /*
// * @inheritDoc
// */
// @Override
// public Object handleGetObject(String key) {
// if (key == null) {
// return "";
// }
//
// Object result = null;
//
// try {
// result = super.handleGetObject(key);
// } catch (Exception e) {
// ;
// }
//
// return (result == null) ? key : result;
// }
// });
// loader.setLocation(/*FXMLPreviewLoader.class.getResource("ColumnExam3.fxml")*/url);
loader.setBuilderFactory(new BuilderFactory() {
@Override
public Builder<?> getBuilder(Class<?> param) {
return new JavaFXBuilderFactory().getBuilder(param);
}
});
loader.setControllerFactory(new Callback<Class<?>, Object>() {
@Override
public Object call(Class<?> param) {
return null;
}
});
FileInputStream inputStream = new FileInputStream(file);
InputStream is = null;
try {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
ByteArrayOutputStream out = new ByteArrayOutputStream();
FXMLSaxHandler handler = new FXMLSaxHandler(out);
sp.parse(inputStream, handler);
String string = out.toString("UTF-8");
string = ValueUtil.regexReplaceMatchs("<!\\[CDATA\\[[?<a-zA-Z. *?>]+]]>", string, str -> {
return ValueUtil.regexMatch("<\\?import [a-zA-Z.*?]+>", str);
});
System.out.println(string);
byte[] bytes = string.getBytes();
is = new ByteArrayInputStream(bytes);
} catch (Exception e) {
e.printStackTrace();
}
// FileInputStream inputStream = new FileInputStream(file);
borderPane.setCenter(loader.load(is));
Scene scene = new Scene(borderPane);
primaryStage.setScene(scene);
primaryStage.show();
}
use of javafx.fxml.JavaFXBuilderFactory in project loinc2hpo by monarch-initiative.
the class Main method init.
@Override
public void init() throws IOException {
final Injector injector = Guice.createInjector(new DepInjectionModule());
final Callback<Class<?>, Object> guiceFactory = clazz -> injector.getInstance(clazz);
rootNode = FXMLLoader.load(getClass().getResource("/fxml/main.fxml"), // The resource bundle, useful to internationalised apps. Null here.
null, new JavaFXBuilderFactory(), // this Guice factory will manage the instantiation of the controllers and their dependency injections.
guiceFactory);
// the following two lines both works; not sure what the first line is
// mainController = injector.getInstance(Key.get(MainController.class));
mainController = injector.getInstance(MainController.class);
}
use of javafx.fxml.JavaFXBuilderFactory in project latexdraw by arnobl.
the class CodeInserter method getInsertCodeDialogue.
/**
* @return The created latexdraw dialogue box.
*/
protected Optional<Stage> getInsertCodeDialogue() {
if (codeInserterDialogue == null) {
try {
// The FXML file only loaded only when this method is called: this JFX controller is created by
// the app injector and lives as a singleton. A call to this function loads the FXML.
final Parent root = // NON-NLS
FXMLLoader.load(// NON-NLS
getClass().getResource("/fxml/InsertCode.fxml"), // NON-NLS
LangTool.INSTANCE.getBundle(), new JavaFXBuilderFactory(), LaTeXDraw.getInstance().getInstanceCallBack());
final Scene scene = new Scene(root);
codeInserterDialogue = new Stage(StageStyle.UTILITY);
codeInserterDialogue.setTitle(LangTool.INSTANCE.getBundle().getString("InsertPSTricksCodeFrame.0"));
codeInserterDialogue.setScene(scene);
codeInserterDialogue.setOnHiding(evt -> setActivated(false));
} catch (final Exception ex) {
BadaboomCollector.INSTANCE.add(ex);
}
}
return Optional.ofNullable(codeInserterDialogue);
}
use of javafx.fxml.JavaFXBuilderFactory in project drbookings by DrBookings.
the class SamplePart method createScene.
protected void createScene(final Composite parent) {
if (logger.isInfoEnabled()) {
logger.info("Initializing FX");
}
try {
final URL location = getClass().getResource("/fxml/FXML.fxml");
final FXMLLoader fXMLLoader = new FXMLLoader();
fXMLLoader.setLocation(location);
fXMLLoader.setBuilderFactory(new JavaFXBuilderFactory());
final Parent root = fXMLLoader.load(location.openStream());
fxmlController = fXMLLoader.getController();
// fxmlController.getZoomManager().start();
final Scene scene = new Scene(root);
fxCanvas.setScene(scene);
if (logger.isInfoEnabled()) {
logger.info("Initializing FX successful");
}
} catch (final Exception e) {
if (logger.isErrorEnabled()) {
logger.error(e.getLocalizedMessage(), e);
}
}
fxmlController.getTable().setItems(manager.getBookings());
}
Aggregations