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 JFoenix by jfoenixadmin.
the class MainController method init.
@PostConstruct
public void init() throws FlowException, VetoException {
// init the title hamburger icon
drawer.setOnDrawerOpening((e) -> {
titleBurger.getAnimation().setRate(1);
titleBurger.getAnimation().play();
});
drawer.setOnDrawerClosing((e) -> {
titleBurger.getAnimation().setRate(-1);
titleBurger.getAnimation().play();
});
titleBurgerContainer.setOnMouseClicked((e) -> {
if (drawer.isHidden() || drawer.isHidding())
drawer.open();
else
drawer.close();
});
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/resources/fxml/ui/popup/MainPopup.fxml"));
loader.setController(new InputController());
toolbarPopup = new JFXPopup(loader.load());
} catch (IOException e1) {
e1.printStackTrace();
}
optionsBurger.setOnMouseClicked((e) -> {
toolbarPopup.show(optionsBurger, PopupVPosition.TOP, PopupHPosition.RIGHT, -12, 15);
});
// create the inner flow and content
context = new ViewFlowContext();
// set the default controller
Flow innerFlow = new Flow(ButtonController.class);
flowHandler = innerFlow.createHandler(context);
context.register("ContentFlowHandler", flowHandler);
context.register("ContentFlow", innerFlow);
drawer.setContent(flowHandler.start(new AnimatedFlowContainer(Duration.millis(320), ContainerAnimations.SWIPE_LEFT)));
context.register("ContentPane", drawer.getContent().get(0));
// side controller will add links to the content flow
Flow sideMenuFlow = new Flow(SideMenuController.class);
sideMenuFlowHandler = sideMenuFlow.createHandler(context);
drawer.setSidePane(sideMenuFlowHandler.start(new AnimatedFlowContainer(Duration.millis(320), ContainerAnimations.SWIPE_LEFT)));
}
use of javafx.fxml.FXMLLoader in project PayFile by mikehearn.
the class Main method overlayUI.
/** Loads the FXML file with the given name, blurs out the main UI and puts this one on top. */
public <T> OverlayUI<T> overlayUI(String name) {
return evalUnchecked(() -> {
checkGuiThread();
// Load the UI from disk.
URL location = getClass().getResource(name);
FXMLLoader loader = new FXMLLoader(location);
Pane ui = loader.load();
T controller = loader.getController();
OverlayUI<T> pair = new OverlayUI<>(ui, controller);
// Auto-magically set the overlayUi member, if it's there.
controller.getClass().getDeclaredField("overlayUi").set(controller, pair);
pair.show();
return pair;
});
}
use of javafx.fxml.FXMLLoader in project PayFile by mikehearn.
the class Main method init.
private void init(Stage mainWindow) throws IOException {
this.mainWindow = mainWindow;
// commented out for now as Modena looks better, but might want to bring this back.
/* if (System.getProperty("os.name").toLowerCase().contains("mac")) {
AquaFx.style();
} */
// Load the GUI. The Controller class will be automagically created and wired up.
URL location = getClass().getResource("main.fxml");
FXMLLoader loader = new FXMLLoader(location);
mainUI = loader.load();
controller = loader.getController();
// Configure the window with a StackPane so we can overlay things on top of the main UI.
uiStack = new StackPane(mainUI);
mainWindow.setTitle(APP_NAME);
final Scene scene = new Scene(uiStack);
// Add CSS that we need.
TextFieldValidator.configureScene(scene);
mainWindow.setScene(scene);
// Make log output concise.
BriefLogFormatter.init();
// Tell bitcoinj to run event handlers on the JavaFX UI thread. This keeps things simple and means
// we cannot forget to switch threads when adding event handlers. Unfortunately, the DownloadListener
// we give to the app kit is currently an exception and runs on a library thread. It'll get fixed in
// a future version. Also note that this doesn't affect the default executor for ListenableFutures.
// That must be specified each time.
Threading.USER_THREAD = Platform::runLater;
// Create the app kit. It won't do any heavyweight initialization until after we start it.
bitcoin = new WalletAppKit(params, new File("."), filePrefix + APP_NAME) {
@Override
protected void addWalletExtensions() throws Exception {
super.addWalletExtensions();
wallet().addExtension(new StoredPaymentChannelClientStates(wallet(), peerGroup()));
}
};
if (params == RegTestParams.get()) {
// You should run a regtest mode bitcoind locally.
bitcoin.connectToLocalHost();
} else if (params == MainNetParams.get()) {
// Checkpoints are block headers that ship inside our app: for a new user, we pick the last header
// in the checkpoints file and then download the rest from the network. It makes things much faster.
// Checkpoint files are made using the BuildCheckpoints tool and usually we have to download the
// last months worth or more (takes a few seconds).
bitcoin.setCheckpoints(getClass().getResourceAsStream("checkpoints"));
}
// Now configure and start the appkit. It won't block for very long.
bitcoin.setDownloadListener(controller.progressBarUpdater()).setBlockingStartup(false).setUserAgent("PayFile Client", "1.0").startAndWait();
// Don't make the user wait for confirmations for now, as the intention is they're sending it their own money!
bitcoin.wallet().allowSpendingUnconfirmedTransactions();
System.out.println(bitcoin.wallet());
controller.onBitcoinSetup();
overlayUI("connect_server.fxml");
mainUI.setVisible(false);
mainWindow.show();
}
use of javafx.fxml.FXMLLoader in project jabref by JabRef.
the class LocalizationParser method getLanguageKeysInFxmlFile.
/**
* Loads the fxml file and returns all used language resources.
*/
private static List<LocalizationEntry> getLanguageKeysInFxmlFile(Path path, LocalizationBundleForTest type) {
List<String> result = new LinkedList<>();
// Record which keys are requested; we pretend that we have all keys
ResourceBundle registerUsageResourceBundle = new ResourceBundle() {
@Override
protected Object handleGetObject(String key) {
result.add(key);
return "test";
}
@Override
public Enumeration<String> getKeys() {
return null;
}
@Override
public boolean containsKey(String key) {
return true;
}
};
PlatformImpl.startup(() -> {
});
try {
FXMLLoader loader = new FXMLLoader(path.toUri().toURL(), registerUsageResourceBundle);
// We don't want to initialize controller
loader.setControllerFactory(controllerType -> null);
// Don't check if root is null (needed for custom controls, where the root value is normally set in the FXMLLoader)
loader.impl_setStaticLoad(true);
loader.load();
} catch (IOException ignore) {
ignore.printStackTrace();
}
return result.stream().map(key -> new LocalizationEntry(path, new LocalizationKey(key).getPropertiesKey(), type)).collect(Collectors.toList());
}
Aggregations