Package javafx.fxml

Examples of javafx.fxml.FXMLLoader


        try {
            refreshStylesheets(scene);

            // Load the main window.
            URL location = getResource("main.fxml");
            FXMLLoader loader = new FXMLLoader(location);
            Pane ui = LHUtils.stopwatched("Loading main.fxml", loader::load);
            ui.setMaxWidth(Double.MAX_VALUE);
            ui.setMaxHeight(Double.MAX_VALUE);
            MainWindow controller = loader.getController();

            // Embed it into a notification pane.
            notificationBar = new NotificationBarPane(ui);

            mainUI = notificationBar;
View Full Code Here


    public <T> OverlayUI<T> overlayUI(String name, @Nullable String title) {
        try {
            checkGuiThread();
            // Load the UI from disk.
            URL location = getResource(name);
            FXMLLoader loader = new FXMLLoader(location);
            Pane ui = loader.load();
            T controller = loader.getController();

            EmbeddedWindow window = null;
            if (title != null)
                ui = window = new EmbeddedWindow(title, ui);
View Full Code Here

import com.google.inject.Injector;


public class InjectingFXMLLoader {
  public static <N> N loadFXML(final Injector injector, URL url) throws IOException {
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(url);
    loader.setBuilderFactory(new JavaFXBuilderFactory());
    loader.setControllerFactory(new Callback<Class<?>, Object>() {
     
      @Override
      public Object call(Class<?> param) {
        return injector.getInstance(param);
      }
    });
   
    InputStream in = url.openStream();
    @SuppressWarnings("unchecked")
    N value = (N) loader.load(in);
    in.close();
       
    return value;
  }
View Full Code Here

  private void saveRefreshContent(final ContentData contentData) {
    folder.setVisible(true);

    ClassLoader cl = null;

    FXMLLoader loader;
    if (contentData.extraJarPath != null && !contentData.extraJarPath.isEmpty() && swtFXContainer != null) {
      final URLClassLoader previewClassLoader = new PreviewURLClassloader(contentData.extraJarPath.toArray(new URL[0]), swtFXContainer.getClass().getClassLoader());

      cl = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(previewClassLoader);

        loader = new FXMLLoader();
        loader.setBuilderFactory(new BuilderFactory() {
          private BuilderFactory f = new JavaFXBuilderFactory(previewClassLoader);
          @Override
          public Builder<?> getBuilder(Class<?> type) {
            return f.getBuilder(type);
          }
        });
        loader.setClassLoader(previewClassLoader);
    } else {
      loader = new FXMLLoader();
    }

    String exception = null;

    try {
      currentFile = contentData.file;
      loader.setStaticLoad(!preference.getBoolean(PREF_LOAD_CONTROLLER, false));
      try {
        // TODO Should we set this to the bin-Folder??
        loader.setLocation(contentData.file.getParent().getLocation().toFile().getAbsoluteFile().toURI().toURL());
      } catch (MalformedURLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }

      if (contentData.resourceBundle != null) {
        FileInputStream in = null;
        try {
          in = new FileInputStream(new File(contentData.resourceBundle));
          Properties p = new Properties();
          p.load(in);

          final Object[][] entries = new Object[p.entrySet().size()][];
          int i = 0;
          for (Entry<Object, Object> e : p.entrySet()) {
            entries[i++] = new Object[] { e.getKey(), e.getValue() };
          }

          ListResourceBundle b = new ListResourceBundle() {

            @Override
            protected Object[][] getContents() {
              return entries;
            }
          };
          loader.setResources(b);
        } catch (Exception e) {
          e.printStackTrace();
        } finally {
          if (in != null) {
            try {
              in.close();
            } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        }
      }

      try {
        document.set(contentData.contents);
        ByteArrayInputStream out = new ByteArrayInputStream(contentData.contents.getBytes());
        Object root = loader.load(out);
        out.close();

        Scene scene = null;
        if (root instanceof Scene) {
          scene = (Scene) root;
          rootPane_new = scene.getRoot();
        } else {
          if( contentData.previewSceneSetup != null ) {
            ByteArrayInputStream sceneOut = new ByteArrayInputStream(contentData.previewSceneSetup.getBytes());
            Object sceneRoot = loader.load(sceneOut);
            if( sceneRoot instanceof Scene ) {
              scene = (Scene) sceneRoot;
            }
          }
         
View Full Code Here

        log.info("Starting Hello JavaFX and Maven demonstration application");

        String fxmlFile = "/fxml/hello.fxml";
        log.debug("Loading FXML for main view from: {}", fxmlFile);
        FXMLLoader loader = new FXMLLoader();
        Parent rootNode = (Parent) loader.load(getClass().getResourceAsStream(fxmlFile));

        log.debug("Showing JFX scene");
        Scene scene = new Scene(rootNode, 400, 200);
        scene.getStylesheets().add("/styles/styles.css");
View Full Code Here

  @Inject
  public DetailsView(BorderPane parent, final MApplication application) {

    URL location = getClass().getResource("details.fxml");

    FXMLLoader fxmlLoader = new FXMLLoader(location);
    controller = new DetailsViewController();
    fxmlLoader.setController(controller);

    Pane root = null;
    try {
      root = (Pane) fxmlLoader.load();
    } catch (IOException e) {
      e.printStackTrace();
    }

    parent.setCenter(root);
View Full Code Here

  public static <O> O load(final ClassLoader classloader, URL url, ResourceBundle resourceBundle, final BuilderFactory builderFactory, Callback<Class<?>, Object> controllerFactory) throws IOException {
    InputStream in = null;
   
    try {
     
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(url);
      loader.setClassLoader(classloader);
      loader.setResources(resourceBundle);
      if( builderFactory == null ) {
        loader.setBuilderFactory(new JavaFXBuilderFactory(classloader))
      } else {
        loader.setBuilderFactory(new BuilderFactory() {
          JavaFXBuilderFactory orgBuilder = new JavaFXBuilderFactory(classloader);
          @Override
          public Builder<?> getBuilder(Class<?> type) {
            Builder<?> b = builderFactory.getBuilder(type);
            if( b == null ) {
              b = orgBuilder.getBuilder(type);
            }
            return b;
          }
        });
      }
     
      if( controllerFactory != null ) {
        loader.setControllerFactory(controllerFactory)
      }
     
      in = url.openStream();
      @SuppressWarnings("unchecked")
      O value = (O) loader.load(in);
      in.close();
     
      return value;
    } finally {
      if( in != null ) {
View Full Code Here

  public ModalDialog(final Modal controller, URL fxml, Window owner, StageStyle style, Modality modality, ResourceBundle bundle) {
    super(style);
    initOwner(owner);
    initModality(modality);
    FXMLLoader loader = new FXMLLoader(fxml);
    loader.setResources(bundle);
    try {
      loader.setControllerFactory(new Callback<Class<?>, Object>() {
        public Object call(Class<?> aClass) {
          return controller;
        }
      });
      controller.setDialog(this);
      scene= new Scene((Parent) loader.load());
      setScene(scene);
    } catch (IOException e) {
      logger.error("Error loading modal class", e);
      throw new RuntimeException(e);
    }
View Full Code Here

  PopupPresentation popupPresentation() {
    return new PopupPresentation(this);
  }

  private Node getNode(final Presentation control, URL location) {
    FXMLLoader loader = new FXMLLoader(location, lang.getBundle());
    loader.setControllerFactory(new Callback<Class<?>, Object>() {
      public Object call(Class<?> aClass) {
        return control;
      }
    });
       
    try {
      return (Node) loader.load();
    } catch (Exception e) {
      logger.error("Error casting node", e);
      return null;
    }
  }
View Full Code Here

TOP

Related Classes of javafx.fxml.FXMLLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.