Java 类javafx.fxml.JavaFXBuilderFactory 实例源码

项目:jedai-ui    文件:WizardMain.java   
@Override
public void start(Stage primaryStage) throws Exception {
    final Injector injector = Guice.createInjector(new WizardModule());

    final URL fxml = WizardMain.class.getClassLoader().getResource("wizard-fxml/Wizard.fxml");

    if (fxml != null) {
        final Parent p = FXMLLoader.load(fxml,
                null,
                new JavaFXBuilderFactory(),
                injector::getInstance
        );

        final Scene scene = new Scene(p);

        primaryStage.setScene(scene);
        primaryStage.setWidth(800);
        primaryStage.setHeight(600);
        primaryStage.setTitle("Java gEneric DAta Integration (JedAI) Toolkit");

        primaryStage.show();
    }
}
项目:OneClient    文件:ContentPanes.java   
public static <T extends ContentPane> T getPane(Class<T> clazz) {
    try {
        ContentPane pane = clazz.newInstance();
        URL fxmlUrl = pane.getFXMLUrl();
        FXMLLoader fxmlLoader = new FXMLLoader(fxmlUrl);
        fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
        pane.setFXMLLoader(fxmlLoader);
        fxmlLoader.setController(pane);
        pane.setNode();
        if (pane.showInSideBar()) {
            panesList.add(pane);
        }
        return fxmlLoader.getController();
    } catch (Exception e) {
        OneClientLogging.error(e);
    }
    return null;
}
项目:OneClient    文件:MinecraftAuthController.java   
public static void openLoginGui() {
    try {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        URL fxmlUrl = classLoader.getResource("gui/mc_auth.fxml");
        if (fxmlUrl == null) {
            OneClientLogging.logger.error("An error has occurred loading mc_auth.fxml!");
            return;
        }
        FXMLLoader fxmlLoader = new FXMLLoader();
        fxmlLoader.setLocation(fxmlUrl);
        fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
        Parent root = fxmlLoader.load(fxmlUrl.openStream());
        Stage stage = new Stage();
        stage.setTitle("One Client - Login to minecraft");
        stage.getIcons().add(new Image("images/icon.png"));
        stage.setResizable(false);
        stage.initOwner(Main.stage);
        stage.initModality(Modality.WINDOW_MODAL);
        Scene scene = new Scene(root, 600, 300);
        scene.getStylesheets().add("gui/css/theme.css");
        stage.setScene(scene);
        stage.initModality(Modality.WINDOW_MODAL);
        stage.initOwner(Main.stage);
        stage.show();
        MinecraftAuthController controller = fxmlLoader.getController();
        controller.stage = stage;
        controller.buttonLogin.setDefaultButton(true);
        controller.showLoginGui();
    } catch (Exception e) {
        OneClientLogging.error(e);
    }
}
项目:OneClient    文件:InstallLocation.java   
public static void getInstallDir(Predicate<File> predicate) throws IOException {
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    URL fxmlUrl = classLoader.getResource("gui/install_location.fxml");
    if (fxmlUrl == null) {
        OneClientLogging.logger.error("An error has occurred loading the fxml!");
    }
    FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(fxmlUrl);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
    Parent root = fxmlLoader.load(fxmlUrl.openStream());
    Stage stage = new Stage();
    stage.setTitle("Select Install Location");
    stage.getIcons().add(new Image("images/icon.png"));
    stage.setResizable(false);
    stage.initOwner(Main.stage);
    stage.initModality(Modality.WINDOW_MODAL);
    Scene scene = new Scene(root, 500, 150);
    scene.getStylesheets().add("gui/css/theme.css");
    stage.setScene(scene);
    stage.show();
    InstallLocation controller = fxmlLoader.getController();
    controller.okButton.setOnAction(event -> {
        predicate.test(new File(controller.locationField.getText()));
        stage.close();
    });
    controller.browseButton.setOnAction(event -> {
        DirectoryChooser directoryChooser = new DirectoryChooser();
        File dir = new File(controller.locationField.getText());
        if (dir.exists())
            directoryChooser.setInitialDirectory(dir);
        File selectedDirectory = directoryChooser.showDialog(stage);
        if (selectedDirectory != null) {
            controller.locationField.setText(selectedDirectory.getAbsolutePath());
        }
    });
    controller.locationField.setText(Constants.getDefaultDir().getAbsolutePath());
}
项目:OneClient    文件:SplashScreen.java   
public static void show() throws IOException {
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    URL fxmlUrl = classLoader.getResource("gui/splash.fxml");
    if (fxmlUrl == null) {
        OneClientLogging.logger.error("An error has occurred loading instance_creation.fxml!");
        return;
    }
    FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(fxmlUrl);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
    Parent root = fxmlLoader.load(fxmlUrl.openStream());
    stage = new Stage();
    stage.setTitle("One Client - Loading");
    stage.getIcons().add(new Image("images/icon.png"));
    stage.setResizable(false);
    stage.initOwner(Main.stage);
    stage.initModality(Modality.WINDOW_MODAL);
    Scene scene = new Scene(root, 600, 400);
    scene.getStylesheets().add("gui/css/theme.css");
    stage.setScene(scene);
    splashScreenController = fxmlLoader.getController();
    stage.show();
    loaded = true;
}
项目:OneClient    文件:OneClientLogging.java   
public static void setupLogController() {
    try {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        URL fxmlUrl = classLoader.getResource("gui/log.fxml");
        if (fxmlUrl == null) {
            OneClientLogging.logger.error("An error has occurred loading instance_creation.fxml!");
            return;
        }
        FXMLLoader fxmlLoader = new FXMLLoader();
        fxmlLoader.setLocation(fxmlUrl);
        fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
        Parent root = fxmlLoader.load(fxmlUrl.openStream());
        stage = new Stage();
        stage.setTitle("One Client - Log");
        stage.getIcons().add(new Image("images/icon.png"));
        stage.setResizable(true);
        stage.setAlwaysOnTop(false);
        stage.initOwner(Main.stage);
        stage.initModality(Modality.NONE);
        Scene scene = new Scene(root, 600, 300);
        scene.getStylesheets().add("gui/css/theme.css");
        stage.setScene(scene);
        logController = fxmlLoader.getController();
        logController.setStage(stage);
        TextAreaAppender.setTextArea(logController.logArea);
    } catch (Exception e) {
        OneClientLogging.error(e);
    }
}
项目:H-Uppaal    文件:QueryPanePresentation.java   
public QueryPanePresentation() {
    final URL location = this.getClass().getResource("QueryPanePresentation.fxml");

    final FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(location);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

    try {
        fxmlLoader.setRoot(this);
        fxmlLoader.load(location.openStream());

        controller = fxmlLoader.getController();

        initializeLeftBorder();
        initializeToolbar();
        initializeBackground();
        initializeAddQueryButton();

    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
项目:H-Uppaal    文件:MessagePresentation.java   
public MessagePresentation(final CodeAnalysis.Message message) {
    this.message = message;

    final URL location = this.getClass().getResource("MessagePresentation.fxml");

    final FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(location);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

    try {
        fxmlLoader.setRoot(this);
        fxmlLoader.load(location.openStream());

        // Initialize
        initializeMessage();
        initializeNearLabel();

    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
项目:H-Uppaal    文件:BackgroundThreadEntryPresentation.java   
public BackgroundThreadEntryPresentation(final Thread thread) {
    this.thread = thread;

    final URL location = this.getClass().getResource("BackgroundThreadEntryPresentation.fxml");

    final FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(location);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

    try {
        fxmlLoader.setRoot(this);
        fxmlLoader.load(location.openStream());

        initializeRippler();
        initializeBackground();
        initializeLabel();
        initializeThreadRunningCheck();

    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
项目:H-Uppaal    文件:ProjectPanePresentation.java   
public ProjectPanePresentation() {
    final URL location = this.getClass().getResource("ProjectPanePresentation.fxml");

    final FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(location);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

    try {
        fxmlLoader.setRoot(this);
        fxmlLoader.load(location.openStream());

        controller = fxmlLoader.getController();

        initializeRightBorder();
        initializeBackground();
        initializeToolbar();

        initializeToolbarButton(controller.createComponent);

    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
项目:H-Uppaal    文件:QueryPresentation.java   
public QueryPresentation(final Query query) {
    final URL location = this.getClass().getResource("QueryPresentation.fxml");

    final FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(location);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

    try {
        fxmlLoader.setRoot(this);
        fxmlLoader.load(location.openStream());

        this.query = query;

        initializeStateIndicator();
        initializeProgressIndicator();
        initializeActionButton();
        initializeDetailsButton();
        initializeTextFields();

    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
项目:H-Uppaal    文件:MessageCollectionPresentation.java   
public MessageCollectionPresentation(final Component component, final ObservableList<CodeAnalysis.Message> messages) {
    this.messages = messages;

    final URL location = this.getClass().getResource("MessageCollectionPresentation.fxml");

    final FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(location);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

    try {
        fxmlLoader.setRoot(this);
        fxmlLoader.load(location.openStream());

        initializeHeadline(component);
        initializeLine();
        initializeErrorsListener();


    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
项目:H-Uppaal    文件:TagPresentation.java   
public TagPresentation() {
    final URL location = this.getClass().getResource("TagPresentation.fxml");

    final FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(location);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

    try {
        fxmlLoader.setRoot(this);
        fxmlLoader.load(location.openStream());

        initializeShape();
        initializeLabel();
        initializeMouseTransparency();
        initializeTextFocusHandler();

    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
项目:H-Uppaal    文件:FilePresentation.java   
public FilePresentation(final Component component) {
    final URL location = this.getClass().getResource("FilePresentation.fxml");

    final FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(location);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

    try {
        fxmlLoader.setRoot(this);
        fxmlLoader.load(location.openStream());

        this.component.set(component);

        initializeIcon();
        initializeFileName();
        initializeColors();
        initializeRippler();
        initializeMoreInformationButton();

    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
项目:Java-9-Programming-Blueprints    文件:PhotoViewerTopComponent.java   
private void createScene() {
    try {
        URL location = getClass().getResource("/fxml/photoviewer.fxml");
        FXMLLoader fxmlLoader = new FXMLLoader();
        fxmlLoader.setLocation(location);
        fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

        Parent root = (Parent) fxmlLoader.load(location.openStream());
        Scene scene = new Scene(root);
        fxPanel.setScene(scene);
        controller = (PhotoViewerController) fxmlLoader.getController();
        controller.setPhoto(photo);
    } catch (IOException ex) {
        LOGGER.log(Level.SEVERE, null, ex);
    }
}
项目:openjfx-8u-dev-tests    文件:staticPropertyLoadApp.java   
@Override
public Node impl_drawNode() throws IOException {
    InputStream is = null;
    try {
        FXMLLoader fxmlLoader2 = new FXMLLoader();
        is = resource.openStream();
        ClassLoader defaultClassLoader = fxmlLoader2.getClassLoader();

        fxmlLoader2.setBuilderFactory(new JavaFXBuilderFactory(defaultClassLoader));
        color = (Color) fxmlLoader2.load(is); // see RT-18091
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("message: " + e.getMessage());
        reportGetterFailure("exception thrown.");
    } finally {
        is.close();
    }
    System.out.println("color: " + color);
    if (color.equals(Color.color(1., 0., 0.))) {
        return retRec;
    } else {
        reportGetterFailure("failed.");
        return redRectangle;
    }
}
项目:openjfx-8u-dev-tests    文件:loadfxmlApp1.java   
@Override
public Node drawNode() {
    Node uplevelNode = null;
    URL resource = getClass().getResource(defaultResourcePath);
    File f = new File(resource.getFile());
    boolean pass = true;
    JavaFXBuilderFactory factory = new JavaFXBuilderFactory();
    if (f.getName().endsWith(".fxml")) {
        System.out.println("loading " + f.getPath());
        try {
            //uplevelNode = FXMLLoader.load(f.toURI().toURL(), null, factory);
            uplevelNode = FXMLLoader.load(loadfxmlApp1.class.getResource(defaultResourcePath), null, factory);
        } catch (Exception e) {
            pass = false;
            System.out.println("message: " + e.getMessage());
        }
    }
    return pass ? uplevelNode : new Rectangle(10, 10, 10, 10) {

        {
            setFill(Color.RED);
        }
    };
}
项目:supernovae    文件:SupernovaeGame.java   
protected Initializable replaceSceneContent(String fxml) throws Exception {
    FXMLLoader loader = new FXMLLoader();
    InputStream in = SupernovaeGame.class.getResourceAsStream(fxml);
    loader.setBuilderFactory(new JavaFXBuilderFactory());
    loader.setLocation(SupernovaeGame.class.getResource(fxml));
    Pane page;
    try {
        page = (Pane) loader.load(in);
    } finally {
        in.close();
    }
    Scene scene = new Scene(page, 800, 600);
    ViewPlatform.JavaFXScene.setValue(scene);
    stage.setScene(scene);
    stage.sizeToScene();
    return (Initializable) loader.getController();
}
项目:examples-javafx-repos1    文件:WizardMain.java   
@Override
public void start(Stage primaryStage) throws Exception {

    final Injector injector = Guice.createInjector( new WizardModule() );

    final Parent p = FXMLLoader.load( WizardMain.class.getResource("/wizard-fxml/Wizard.fxml"),
                                      null,
                                      new JavaFXBuilderFactory(),
                                      (clazz) -> injector.getInstance(clazz)
    );

    final Scene scene = new Scene(p);

    primaryStage.setScene( scene );
    primaryStage.setWidth( 800 );
    primaryStage.setHeight( 600 );
    primaryStage.setTitle("Wizard");

    primaryStage.show();
}
项目:examples-javafx-repos1    文件:OldScoresModule.java   
@Override
protected void configure() {

    String mathRecenteredJSONFile = MATH_RECENTERED_JSON_FILE;
    String verbalRecenteredJSONFile = VERBAL_RECENTERED_JSON_FILE;
    String settingsFileName = SETTINGS_FILE_NAME;

    bind(BuilderFactory.class).to(JavaFXBuilderFactory.class);

    bind(String.class).annotatedWith(Names.named("mathRecenteredJSONFile")).toInstance(mathRecenteredJSONFile);
    bind(String.class).annotatedWith(Names.named("verbalRecenteredJSONFile")).toInstance(verbalRecenteredJSONFile);
    bind(String.class).annotatedWith(Names.named("settingsFileName")).toInstance(settingsFileName);

    bind(SettingsDAO.class).to(SettingsDAOImpl.class).asEagerSingleton();
    bind(RecenteredDAO.class).to(RecenteredDAOImpl.class).asEagerSingleton();

    bindInterceptor(Matchers.subclassesOf(ManagedDataSource.class), Matchers.any(), new ManagedDataSourceInterceptor());
}
项目:examples-javafx-repos1    文件:OldScoresModule.java   
@Override
protected void configure() {

    String mathRecenteredJSONFile = MATH_RECENTERED_JSON_FILE;
    String verbalRecenteredJSONFile = VERBAL_RECENTERED_JSON_FILE;
    String settingsFileName = SETTINGS_FILE_NAME;

    bind(BuilderFactory.class).to(JavaFXBuilderFactory.class);

    bind(String.class).annotatedWith(Names.named("mathRecenteredJSONFile")).toInstance(mathRecenteredJSONFile);
    bind(String.class).annotatedWith(Names.named("verbalRecenteredJSONFile")).toInstance(verbalRecenteredJSONFile);
    bind(String.class).annotatedWith(Names.named("settingsFileName")).toInstance(settingsFileName);

    bind(SettingsDAO.class).to(SettingsDAOImpl.class).asEagerSingleton();
    bind(RecenteredDAO.class).to(RecenteredDAOImpl.class).asEagerSingleton();
}
项目:examples-javafx-repos1    文件:OldScoresModule.java   
@Override
protected void configure() {

    String mathRecenteredJSONFile = MATH_RECENTERED_JSON_FILE;
    String verbalRecenteredJSONFile = VERBAL_RECENTERED_JSON_FILE;
    String settingsFileName = SETTINGS_FILE_NAME;

    bind(BuilderFactory.class).to(JavaFXBuilderFactory.class);

    bind(String.class).annotatedWith(Names.named("mathRecenteredJSONFile")).toInstance(mathRecenteredJSONFile);
    bind(String.class).annotatedWith(Names.named("verbalRecenteredJSONFile")).toInstance(verbalRecenteredJSONFile);
    bind(String.class).annotatedWith(Names.named("settingsFileName")).toInstance(settingsFileName);

    bind(SettingsDAO.class).to(SettingsDAOImpl.class).asEagerSingleton();
    bind(RecenteredDAO.class).to(RecenteredDAOImpl.class).asEagerSingleton();

    bindInterceptor(Matchers.subclassesOf(ManagedDataSource.class), Matchers.any(), new ManagedDataSourceInterceptor());
}
项目:test-javafx    文件:FxmlLoaderServiceImpl.java   
/**
 * When creating the controller, use Guice to inject dependencies into it first and then register it to the event bus
 * before returning it.
 *
 * @param fxmlEnum FXML Enum
 * @return Node
 */
@Override
public Parent load(final FxmlEnum fxmlEnum) {
    try {
        return FXMLLoader.load(Resources.getResource(fxmlEnum.getPath()),
                               null,
                               new JavaFXBuilderFactory(),
                               clazz -> {
                                   final Object controller = injector.getInstance(clazz);
                                   eventBus.register(controller);
                                   return controller;
                               });
    }
    catch (IOException e) {
        throw new RuntimeException("Unable to load FXML from path: " + fxmlEnum.getPath(), e);
    }
}
项目:epubfx    文件:EditorTabManager.java   
public ImageViewerPane()
{
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/image_view.fxml"), null, new JavaFXBuilderFactory(),
            type -> BeanFactory.getInstance().getBean(type));
    loader.setRoot(this);
    loader.setController(this);

    try
    {
        loader.load();
    }
    catch (IOException e)
    {
        ExceptionDialog.showAndWait(e, null,  "Bild anzeigen", "Fehler beim Öffnen eines Bildes.");
        logger.error("", e);
    }
}
项目:epubfx    文件:EpubEditorMainController.java   
public void addCoverAction(ActionEvent actionEvent)
{
    Stage addCoverStage = new Stage(StageStyle.UTILITY);
    try
    {
        FXMLLoader loader = new FXMLLoader(EpubEditorMainController.class.getResource("/add_cover.fxml"), null, new JavaFXBuilderFactory(),
                type -> BeanFactory.getInstance().getBean(type));
        Pane root = loader.load();

        Scene scene = new Scene(root);

        AddCoverController addCoverController = AddCoverController.getInstance();
        addCoverController.setBook(currentBookProperty.getValue());
        addCoverController.setStage(addCoverStage);
        addCoverController.setBookBrowserManager(bookBrowserManager);

        addCoverStage.setScene(scene);
        addCoverStage.initOwner(stage);
        addCoverStage.initModality(Modality.APPLICATION_MODAL);
    }
    catch (IOException e)
    {
        logger.error("cannot open edit window", e);
    }
    addCoverStage.show();
}
项目:epubfx    文件:EpubEditorMainController.java   
public void editMetadataAction(ActionEvent actionEvent)
{
    Stage editMetadataStage = new Stage(StageStyle.UTILITY);
    try
    {
        FXMLLoader loader = new FXMLLoader(EpubEditorMainController.class.getResource("/metadata_editor.fxml"), null, new JavaFXBuilderFactory(),
                type -> BeanFactory.getInstance().getBean(type));
        Pane root = loader.load();

        Scene scene = new Scene(root);

        EditMetadataController controller = EditMetadataController.getInstance();
        controller.setBook(currentBookProperty.getValue());
        controller.setStage(editMetadataStage);

        editMetadataStage.setScene(scene);
        editMetadataStage.initOwner(stage);
        editMetadataStage.initModality(Modality.APPLICATION_MODAL);
    }
    catch (IOException e)
    {
        logger.error("cannot open edit window", e);
    }
    editMetadataStage.show();
}
项目:epubfx    文件:UIHelper.java   
public Stage createChooserWindow()
{
    Stage chooserWindowStage = new Stage(StageStyle.UTILITY);
    try
    {
        FXMLLoader loader = new FXMLLoader(UIHelper.class.getResource("/ChooserWindow.fxml"), null, new JavaFXBuilderFactory(),
                type -> BeanFactory.getInstance().getBean(type));
        Pane root = loader.load();
        Scene scene = new Scene(root);

        ChooserWindowController chooserWindowController = ChooserWindowController.getInstance();
        chooserWindowController.setChooserWindow(chooserWindowStage);

        chooserWindowStage.setScene(scene);
        chooserWindowStage.initOwner(configuration.getMainWindow());
        chooserWindowStage.initModality(Modality.APPLICATION_MODAL);
        chooserWindowStage.setTitle("Auswahl");
    }
    catch (IOException e)
    {
        logger.error("cannot open chooser window", e);
    }
    return chooserWindowStage;
}
项目:epubfx    文件:SearchAnchorPane.java   
public SearchAnchorPane()
{
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/search_pane.fxml"), null, new JavaFXBuilderFactory());
    loader.setRoot(this);
    loader.setController(this);

    try
    {
        loader.load();
    }
    catch (IOException e)
    {
        ExceptionDialog.showAndWait(e, null, "Suchmaske", "Fehler beim Öffnen der Suchmaske");
        logger.error("", e);
    }
}
项目:updatefx    文件:UpdateController.java   
public static void performUpdate(Release release, URL css) {
    try {
        ResourceBundle i18nBundle = ResourceBundle.getBundle("com.briksoftware.updatefx.gui.i18n.UpdateProgressDialog");

        FXMLLoader loader = new FXMLLoader(UpdateController.class.getResource("UpdateProgressDialog.fxml"), i18nBundle);
        loader.setBuilderFactory(new JavaFXBuilderFactory());
        Parent page = loader.load();
        UpdateController controller = loader.getController();
        controller.release = release;
        controller.initialize();

        Scene scene = new Scene(page);
        if (css != null) {
            scene.getStylesheets().add(css.toExternalForm());
        }

        final Stage stage = new Stage();
        stage.setScene(scene);
        stage.show();
        stage.toFront();

    } catch (Throwable ex) {
        ex.printStackTrace();
    }
}
项目:vars    文件:JFXMovieJFrame.java   
private JFXMovieJFrameController initJFXNodes(final String location, Consumer<JFXMovieJFrameController> onReadyRunnable) throws IOException {
    URL controllerLocation = getClass().getResource("/fxml/JFXMovieJFrame.fxml");
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(controllerLocation);
    loader.setBuilderFactory(new JavaFXBuilderFactory());

    Parent root = loader.load(controllerLocation.openStream());
    controller = loader.getController();
    controller.setMediaLocation(location, onReadyRunnable);

    Scene scene = new Scene(root);
    scene.getStylesheets().add("/styles/JFXMovieFrame.css");
    panel.setScene(scene);

    MediaView mediaView = controller.getMediaView();
    mediaView.setFitWidth(getWidth());
    mediaView.setFitHeight(getHeight());
    return controller;
}
项目:script-runner-gui    文件:App.java   
@Override
public void start(Stage primaryStage) throws Exception {
    URL location = getClass().getResource(MAIN_FXML_FILE);

    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(location);
    loader.setBuilderFactory(new JavaFXBuilderFactory());

    Parent root = (Parent) loader.load(location.openStream());

    MainController mainController = loader.getController();
    mainController.setStage(primaryStage);

    Scene scene = new Scene(root);

    primaryStage.setTitle("Script runner");
    primaryStage.setScene(scene);
    primaryStage.show();
}
项目:jedai-ui    文件:MethodConfiguration.java   
/**
 * Display the window with the automatically generated form that allows the user to set a method's parameters.
 *
 * @param callerClass Class to get class loader from, to use for loading the window's FXML file
 * @param injector    Injector to use when loading FXML, so that the model etc. are injected automatically.
 * @param method      Method that the window should display configuration options for.
 */
public static void displayModal(Class callerClass, Injector injector, IDocumentation method, ListProperty<JPair<String, Object>> paramsProperty) {
    Parent root;
    FXMLLoader loader = new FXMLLoader(
            callerClass.getClassLoader().getResource("wizard-fxml/DynamicConfiguration.fxml"),
            null,
            new JavaFXBuilderFactory(),
            injector::getInstance
    );

    try {
        root = loader.load();
    } catch (IOException e) {
        e.printStackTrace();
        return;
    }

    root.getProperties().put("controller", loader.getController());

    Object controller = loader.getController();
    if (controller instanceof DynamicConfigurationController) {
        // Cast the controller instance since we know it's safe here
        DynamicConfigurationController popupController = (DynamicConfigurationController) controller;

        // Give the configuration options to the controller
        JsonArray params = method.getParameterConfiguration();
        popupController.setParameters(params, paramsProperty);

        // Create the popup
        Stage dialog = new Stage();
        dialog.setScene(new Scene(root));
        dialog.setTitle("JedAI - Parameter Configuration");
        dialog.initModality(Modality.APPLICATION_MODAL);

        dialog.show();
    } else {
        // This shouldn't ever happen.
        System.err.println("Error when showing the parameter customization popup (Wrong controller instance?)");
    }
}
项目:jedai-ui    文件:WizardController.java   
private void buildSteps() throws java.io.IOException {
    final JavaFXBuilderFactory bf = new JavaFXBuilderFactory();

    final Callback<Class<?>, Object> cb = (clazz) -> injector.getInstance(clazz);

    // Specify step FXMLs in order that they should appear
    ArrayList<String> controllers = new ArrayList<>(Arrays.asList(
            "wizard-fxml/steps/Step0.fxml",
            "wizard-fxml/steps/Step1.fxml",
            "wizard-fxml/steps/Step2.fxml",
            "wizard-fxml/steps/Step3.fxml",
            "wizard-fxml/steps/Step4.fxml",
            "wizard-fxml/steps/Step5.fxml",
            "wizard-fxml/steps/Step6.fxml",
            "wizard-fxml/steps/Confirm.fxml",
            "wizard-fxml/steps/Completed.fxml"
    ));

    // Create steps and add them to the list
    for (String ctrlPath : controllers) {
        // Create step
        FXMLLoader loader = new FXMLLoader(WizardController.class.getClassLoader().getResource(ctrlPath), null, bf, cb);
        Parent step = loader.load();
        step.getProperties().put(CONTROLLER_KEY, loader.getController());

        // Add step to steps list
        steps.add(step);
    }
}
项目:LIRE-Lab    文件:LireLabBuiderFactory.java   
@Override
public Builder<?> getBuilder(Class<?> type) {
    if(type == ImageGrid.class) {
        return new ImageGridBuilder(imageViewFactory, fileUtils);
    }

    return new JavaFXBuilderFactory().getBuilder(type);
}
项目:OneClient    文件:NewInstanceController.java   
public static void start(Instance instance) {
    //TODO DEDUPLICATE THIS
    if (!MinecraftAuthController.isUserValid()) {
        MinecraftAuthController.updateGui();
        //TODO replace with a login request
        OneClientLogging.alert("You must log into minecraft to play the game!", "You are not logged in!");
        return;
    }
    try {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        URL fxmlUrl = classLoader.getResource("gui/instance_creation.fxml");
        if (fxmlUrl == null) {
            OneClientLogging.logger.error("An error has occurred loading instance_creation.fxml!");
            return;
        }
        FXMLLoader fxmlLoader = new FXMLLoader();
        fxmlLoader.setLocation(fxmlUrl);
        fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
        Parent root = fxmlLoader.load(fxmlUrl.openStream());
        stage = new Stage();
        stage.setTitle("One Client - Create New Instance");
        stage.getIcons().add(new Image("images/icon.png"));
        stage.setResizable(false);
        stage.initOwner(Main.stage);
        stage.initModality(Modality.WINDOW_MODAL);
        Scene scene = new Scene(root, 600, 300);
        scene.getStylesheets().add("gui/css/theme.css");
        stage.setScene(scene);
        stage.show();
        NewInstanceController controller = fxmlLoader.getController();
        controller.instance = instance;
        controller.onStart(stage);
    } catch (Exception e) {
        OneClientLogging.error(e);
    }
}
项目:OneClient    文件:Main.java   
public void startLauncher() throws Exception {
    OneClientLogging.logger.info("Starting One Client");
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    URL fxmlUrl = classLoader.getResource("gui/main.fxml");
    if (fxmlUrl == null) {
        OneClientLogging.logger.error("An error has occurred loading main.fxml!");
        return;
    }
    FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(fxmlUrl);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
    Parent root = fxmlLoader.load(fxmlUrl.openStream());
    if (Constants.getVersion() == null) {
        stage.setTitle("One Client");
    } else {
        stage.setTitle("One Client " + Constants.getVersion());
    }
    stage.getIcons().add(new Image("images/icon.png"));
    scene = new Scene(root, 1288, 800);
    scene.getStylesheets().add("gui/css/theme.css");
    stage.setScene(scene);
    stage.show();
    stage.setOnCloseRequest(event -> {
        OneClientLogging.stage.close();
        OneClientLogging.logger.info("Goodbye");
        System.exit(0);
    });
    mainController = fxmlLoader.getController();
    scene.widthProperty().addListener((observableValue, oldSceneWidth, newSceneWidth) -> mainController.onSceneResize(scene));
    scene.heightProperty().addListener((observableValue, oldSceneWidth, newSceneWidth) -> mainController.onSceneResize(scene));
    mainController.onStart(stage);
    MinecraftAuthController.load();
}
项目:H-Uppaal    文件:NailPresentation.java   
public NailPresentation(final Nail nail, final Edge edge,final Component component) {
    final URL url = this.getClass().getResource("NailPresentation.fxml");

    final FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(url);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

    try {
        fxmlLoader.setRoot(this);
        fxmlLoader.load(url.openStream());

        controller = fxmlLoader.getController();

        // Bind the component with the one of the controller
        controller.setComponent(component);

        // Bind the edge with the one of the controller
        controller.setEdge(edge);

        // Bind the nail with the one of the controller
        controller.setNail(nail);

        initializeNailCircleColor();
        initializePropertyTag();
        initializeRadius();
        initializeShakeAnimation();

    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
项目:H-Uppaal    文件:LocationPresentation.java   
public LocationPresentation(final Location location, final Component component, final boolean interactable) {
    this.interactable = interactable;
    final URL url = this.getClass().getResource("LocationPresentation.fxml");

    final FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(url);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

    try {
        fxmlLoader.setRoot(this);
        fxmlLoader.load(url.openStream());

        controller = fxmlLoader.getController();

        // Bind the component with the one of the controller
        controller.setComponent(component);

        // Bind the location with the one of the controller
        controller.setLocation(location);

        controller.initializeInvalidNameError();

        initializeIdLabel();
        initializeTypeGraphics();
        initializeLocationShapes();
        initializeTags();
        initializeInitialAnimation();
        initializeHoverAnimationEntered();
        initializeHoverAnimationExited();
        initializeDeleteShakeAnimation();
        initializeShakeAnimation();
        initializeCircle();
        initializeReachabilityStyle();

    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
项目:H-Uppaal    文件:UndoRedoHistoryEntryPresentation.java   
public UndoRedoHistoryEntryPresentation(final UndoRedoStack.Command command, final boolean isUndo) {
    this.command = command;

    final URL location = this.getClass().getResource("UndoRedoHistoryEntryPresentation.fxml");

    final FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(location);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

    try {
        fxmlLoader.setRoot(this);
        fxmlLoader.load(location.openStream());

        // Must be the indicator for the current state
        if (command == null) {
            color = Color.GREY_BLUE;
            colorIntensity = Color.Intensity.I500;
        } else if (isUndo) {
            color = Color.GREEN;
            colorIntensity = Color.Intensity.I600;
        } else {
            color = Color.DEEP_ORANGE;
            colorIntensity = Color.Intensity.I800;
        }

        initializeRippler();
        initializeIcon();
        initializeBackground();
        initializeLabel();

    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
项目:H-Uppaal    文件:UndoRedoHistoryPresentation.java   
public UndoRedoHistoryPresentation() {
    final URL location = this.getClass().getResource("UndoRedoHistoryPresentation.fxml");

    final FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(location);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

    try {
        fxmlLoader.setRoot(this);
        fxmlLoader.load(location.openStream());

    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}