Search in sources :

Example 61 with FXMLLoader

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);
    }
}
Also used : FXMLLoader(javafx.fxml.FXMLLoader)

Example 62 with FXMLLoader

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)));
}
Also used : ViewFlowContext(io.datafx.controller.flow.context.ViewFlowContext) FXMLViewFlowContext(io.datafx.controller.flow.context.FXMLViewFlowContext) IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader) Flow(io.datafx.controller.flow.Flow) AnimatedFlowContainer(demos.datafx.AnimatedFlowContainer) PostConstruct(javax.annotation.PostConstruct)

Example 63 with FXMLLoader

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;
    });
}
Also used : FXMLLoader(javafx.fxml.FXMLLoader) StackPane(javafx.scene.layout.StackPane) Pane(javafx.scene.layout.Pane) URL(java.net.URL)

Example 64 with FXMLLoader

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();
}
Also used : Platform(javafx.application.Platform) StoredPaymentChannelClientStates(com.google.bitcoin.protocols.channels.StoredPaymentChannelClientStates) WalletAppKit(com.google.bitcoin.kits.WalletAppKit) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) File(java.io.File) URL(java.net.URL) StackPane(javafx.scene.layout.StackPane) OptionException(joptsimple.OptionException) IOException(java.io.IOException) BlockStoreException(com.google.bitcoin.store.BlockStoreException)

Example 65 with FXMLLoader

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());
}
Also used : Properties(java.util.Properties) SortedSet(java.util.SortedSet) Files(java.nio.file.Files) Enumeration(java.util.Enumeration) Set(java.util.Set) IOException(java.io.IOException) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) List(java.util.List) Matcher(java.util.regex.Matcher) ResourceBundle(java.util.ResourceBundle) Paths(java.nio.file.Paths) FXMLLoader(javafx.fxml.FXMLLoader) PlatformImpl(com.sun.javafx.application.PlatformImpl) Pattern(java.util.regex.Pattern) LinkedList(java.util.LinkedList) Path(java.nio.file.Path) InputStream(java.io.InputStream) ResourceBundle(java.util.ResourceBundle) IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader) LinkedList(java.util.LinkedList)

Aggregations

FXMLLoader (javafx.fxml.FXMLLoader)113 IOException (java.io.IOException)67 Scene (javafx.scene.Scene)37 Parent (javafx.scene.Parent)33 Stage (javafx.stage.Stage)28 URL (java.net.URL)24 FXML (javafx.fxml.FXML)24 Pane (javafx.scene.layout.Pane)24 ActionEvent (javafx.event.ActionEvent)18 AnchorPane (javafx.scene.layout.AnchorPane)18 ResourceBundle (java.util.ResourceBundle)16 BorderPane (javafx.scene.layout.BorderPane)16 Initializable (javafx.fxml.Initializable)14 JFXButton (com.jfoenix.controls.JFXButton)13 StackPane (javafx.scene.layout.StackPane)13 KeyFrame (javafx.animation.KeyFrame)12 Timeline (javafx.animation.Timeline)12 Duration (javafx.util.Duration)12 Level (java.util.logging.Level)11 Logger (java.util.logging.Logger)11