Java Code Examples for javafx.fxml.FXMLLoader#setClassLoader()

The following examples show how to use javafx.fxml.FXMLLoader#setClassLoader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClickableBitcoinAddress.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
public ClickableBitcoinAddress() {
    try {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("bitcoin_address.fxml"));
        loader.setRoot(this);
        loader.setController(this);
        // The following line is supposed to help Scene Builder, although it doesn't seem to be needed for me.
        loader.setClassLoader(getClass().getClassLoader());
        loader.load();

        AwesomeDude.setIcon(copyWidget, AwesomeIcon.COPY);
        Tooltip.install(copyWidget, new Tooltip("Copy address to clipboard"));

        AwesomeDude.setIcon(qrCode, AwesomeIcon.QRCODE);
        Tooltip.install(qrCode, new Tooltip("Show a barcode scannable with a mobile phone for this address"));

        addressStr = convert(address);
        addressLabel.textProperty().bind(addressStr);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example 2
Source File: FindTextWidget.java    From BowlerStudio with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("restriction")
@Override
public void start(Stage primaryStage) throws Exception {
	this.primaryStage = primaryStage;
	FXMLLoader loader = AssetFactory.loadLayout("layout/findWidget.fxml", true);
	Parent root;
	loader.setController(this);
	// This is needed when loading on MAC
	loader.setClassLoader(getClass().getClassLoader());
	root = loader.load();

	Platform.runLater(() -> {
		primaryStage.setTitle("Find/Replace");
		Scene scene = new Scene(root);
		primaryStage.setScene(scene);
		// primaryStage.initModality(Modality.WINDOW_MODAL);
		primaryStage.setResizable(true);
		primaryStage.show();
	});
}
 
Example 3
Source File: BowlerConnectionMenu.java    From BowlerStudio with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("restriction")
@Override
public void start(Stage primaryStage) throws Exception {
	this.primaryStage = primaryStage;
	FXMLLoader loader = AssetFactory.loadLayout("layout/BowlerConnectionMenu.fxml", true);
	Parent root;
	loader.setController(this);
	// This is needed when loading on MAC
	loader.setClassLoader(getClass().getClassLoader());
	root = loader.load();

	Platform.runLater(() -> {
		primaryStage.setTitle("Bowler Device Connection");

		Scene scene = new Scene(root);
		primaryStage.setScene(scene);
		primaryStage.initModality(Modality.WINDOW_MODAL);
		primaryStage.setResizable(true);
		primaryStage.show();

	});
}
 
Example 4
Source File: ChangeAssetRepoController.java    From BowlerStudio with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("restriction")
@Override
public void start(Stage primaryStage) throws Exception {
	FXMLLoader loader = AssetFactory.loadLayout("layout/changeAssetRepo.fxml", true);
	Parent root;
	loader.setController(this);
	// This is needed when loading on MAC
	loader.setClassLoader(getClass().getClassLoader());
	root = loader.load();

	Platform.runLater(() -> {
		primaryStage.setTitle("Change Asset Repository");

		Scene scene = new Scene(root);
		primaryStage.setScene(scene);
		primaryStage.initModality(Modality.WINDOW_MODAL);
		primaryStage.setResizable(true);
		primaryStage.show();
	});
}
 
Example 5
Source File: JogTrainerWidget.java    From BowlerStudio with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("restriction")
@Override
   public void start(Stage primaryStage) throws Exception
   {      
   	this.primaryStage = primaryStage;
	FXMLLoader loader = AssetFactory.loadLayout("layout/jogTrainerWidget.fxml", true);
   	Parent root;
   	loader.setController(this);
	// This is needed when loading on MAC
	loader.setClassLoader(getClass().getClassLoader());
       root = loader.load();
       Platform.runLater(() -> {
           primaryStage.setTitle("Configure the controller");

               Scene scene = new Scene(root);
               primaryStage.setScene(scene);
               primaryStage.initModality(Modality.WINDOW_MODAL);
               primaryStage.setResizable(true);
               primaryStage.show();

       });
   }
 
Example 6
Source File: NewVitaminWizardController.java    From BowlerStudio with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
	FXMLLoader loader = AssetFactory.loadLayout("layout/newVitaminWizard.fxml",true);
	Parent root;
	//loader.setController(this);
	// This is needed when loading on MAC
	loader.setClassLoader(getClass().getClassLoader());
	root = loader.load();
	Platform.runLater(() -> {
		primaryStage.setTitle("Edit Vitamins Wizard");

		Scene scene = new Scene(root);
		primaryStage.setScene(scene);
		primaryStage.initModality(Modality.WINDOW_MODAL);
		primaryStage.setResizable(true);
		primaryStage.show();
	});
}
 
Example 7
Source File: ClickableBitcoinAddress.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
public ClickableBitcoinAddress() {
    try {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("bitcoin_address.fxml"));
        loader.setRoot(this);
        loader.setController(this);
        // The following line is supposed to help Scene Builder, although it doesn't seem to be needed for me.
        loader.setClassLoader(getClass().getClassLoader());
        loader.load();

        AwesomeDude.setIcon(copyWidget, AwesomeIcon.COPY);
        Tooltip.install(copyWidget, new Tooltip("Copy address to clipboard"));

        AwesomeDude.setIcon(qrCode, AwesomeIcon.QRCODE);
        Tooltip.install(qrCode, new Tooltip("Show a barcode scannable with a mobile phone for this address"));

        addressStr = convert(address);
        addressLabel.textProperty().bind(addressStr);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example 8
Source File: ClickableBitcoinAddress.java    From devcoretalk with GNU General Public License v2.0 6 votes vote down vote up
public ClickableBitcoinAddress() {
    try {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("bitcoin_address.fxml"));
        loader.setRoot(this);
        loader.setController(this);
        // The following line is supposed to help Scene Builder, although it doesn't seem to be needed for me.
        loader.setClassLoader(getClass().getClassLoader());
        loader.load();

        AwesomeDude.setIcon(copyWidget, AwesomeIcon.COPY);
        Tooltip.install(copyWidget, new Tooltip("Copy address to clipboard"));

        AwesomeDude.setIcon(qrCode, AwesomeIcon.QRCODE);
        Tooltip.install(qrCode, new Tooltip("Show a barcode scannable with a mobile phone for this address"));

        addressStr = convert(address);
        addressLabel.textProperty().bind(addressStr);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example 9
Source File: Controller.java    From xdat_editor with MIT License 5 votes vote down vote up
private Node loadScriptTabContent() {
    try {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("scripting/main.fxml"));
        loader.setClassLoader(getClass().getClassLoader());
        loader.setControllerFactory(param -> new acmi.l2.clientmod.xdat.scripting.Controller(editor));
        return wrap(loader.load());
    } catch (IOException e) {
        log.log(Level.WARNING, "Couldn't load script console", e);
    }
    return null;
}
 
Example 10
Source File: FXUtilities.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Loads and initializes widget from JRXML definition provided in this module.
 * The JRXML file shall be in the same package than the given {@code loader} class
 * and have the same simple name followed by the {@code ".fxml"} extension.
 *
 * @param  target  the widget for which to load the JRXML file.
 * @param  loader  the class to use for loading the file.
 * @throws IOException if an error occurred while loading the JRXML file.
 */
public static void loadJRXML(final Parent target, final Class<?> loader) throws IOException {
    final FXMLLoader fxl = new FXMLLoader(loader.getResource(loader.getSimpleName() + ".fxml"), Resources.getInstance());
    fxl.setRoot(target);
    fxl.setController(target);
    /*
     * In some environements like OSGi, we must use the class loader of the widget
     * (not the class loader of FXMLLoader).
     */
    fxl.setClassLoader(loader.getClassLoader());
    fxl.load();
}
 
Example 11
Source File: XdatEditor.java    From xdat_editor with MIT License 4 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    this.stage = primaryStage;

    FXMLLoader loader = new FXMLLoader(getClass().getResource("main.fxml"), interfaceResources);
    loader.setClassLoader(getClass().getClassLoader());
    loader.setControllerFactory(param -> new Controller(XdatEditor.this));
    Parent root = loader.load();
    controller = loader.getController();

    primaryStage.setTitle("XDAT Editor");
    primaryStage.setScene(new Scene(root));
    primaryStage.setWidth(Double.parseDouble(windowPrefs().get("width", String.valueOf(primaryStage.getWidth()))));
    primaryStage.setHeight(Double.parseDouble(windowPrefs().get("height", String.valueOf(primaryStage.getHeight()))));
    if (windowPrefs().getBoolean("maximized", primaryStage.isMaximized())) {
        primaryStage.setMaximized(true);
    } else {
        Rectangle2D bounds = new Rectangle2D(
                Double.parseDouble(windowPrefs().get("x", String.valueOf(primaryStage.getX()))),
                Double.parseDouble(windowPrefs().get("y", String.valueOf(primaryStage.getY()))),
                primaryStage.getWidth(),
                primaryStage.getHeight());
        if (Screen.getScreens()
                .stream()
                .map(Screen::getVisualBounds)
                .anyMatch(r -> r.intersects(bounds))) {
            primaryStage.setX(bounds.getMinX());
            primaryStage.setY(bounds.getMinY());
        }
    }
    primaryStage.show();

    Platform.runLater(() -> {
        InvalidationListener listener = observable -> {
            if (primaryStage.isMaximized()) {
                windowPrefs().putBoolean("maximized", true);
            } else {
                windowPrefs().putBoolean("maximized", false);
                windowPrefs().put("x", String.valueOf(Math.round(primaryStage.getX())));
                windowPrefs().put("y", String.valueOf(Math.round(primaryStage.getY())));
                windowPrefs().put("width", String.valueOf(Math.round(primaryStage.getWidth())));
                windowPrefs().put("height", String.valueOf(Math.round(primaryStage.getHeight())));
            }
        };
        primaryStage.xProperty().addListener(listener);
        primaryStage.yProperty().addListener(listener);
        primaryStage.widthProperty().addListener(listener);
        primaryStage.heightProperty().addListener(listener);
    });
    Platform.runLater(this::postShow);
}
 
Example 12
Source File: AddFileToGistController.java    From BowlerStudio with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("restriction")
@Override
public void start(Stage primaryStage) throws Exception {
	FXMLLoader loader = AssetFactory.loadLayout("layout/addFileToGist.fxml", true);
	Parent root;
	loader.setController(this);
	// This is needed when loading on MAC
	loader.setClassLoader(getClass().getClassLoader());
	root = loader.load();
	extention.getItems().clear();
	List<String> langs = ScriptingEngine.getAllLangauges();
	ObservableList<String> options = FXCollections.observableArrayList(langs);
	//
	for(String s:options){
		extention.getItems().add(s);
	}
	extention.getSelectionModel().select("Groovy");
	Image icon;
	String asset = "Script-Tab-" + extention.getSelectionModel().getSelectedItem() + ".png";
	
	try {
		
		icon = AssetFactory.loadAsset(asset);
		langaugeIcon.setImage(icon);
	} catch (Exception e2) {
		// TODO Auto-generated catch block
		e2.printStackTrace();
	}

	extention.setOnAction(event -> {
		try {

			langaugeIcon.setImage(AssetFactory
					.loadAsset(asset));
			String key = extention.getSelectionModel().getSelectedItem();
			IScriptingLanguage l  = ScriptingEngine
					.getLangaugesMap()
					.get(key);
			if(l!=null){
				extentionStr= "."+l.getFileExtenetion()
						.get(0);
			}
			else
				extentionStr=".groovy";
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

	});

	Platform.runLater(() -> {
		primaryStage.setTitle("Add File to Git Repo "+gitRepo);

		Scene scene = new Scene(root);
		primaryStage.setScene(scene);
		primaryStage.initModality(Modality.WINDOW_MODAL);
		primaryStage.setResizable(true);
		primaryStage.show();
	});
}
 
Example 13
Source File: InternalFXMLLoader.java    From logbook-kai with MIT License 4 votes vote down vote up
public static FXMLLoader load(URL url) throws IOException {
    FXMLLoader loader = new FXMLLoader(url);
    loader.setClassLoader(PluginServices.getClassLoader());
    return loader;
}