当前位置: 首页>>代码示例>>Java>>正文


Java FXMLLoader.setClassLoader方法代码示例

本文整理汇总了Java中javafx.fxml.FXMLLoader.setClassLoader方法的典型用法代码示例。如果您正苦于以下问题:Java FXMLLoader.setClassLoader方法的具体用法?Java FXMLLoader.setClassLoader怎么用?Java FXMLLoader.setClassLoader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.fxml.FXMLLoader的用法示例。


在下文中一共展示了FXMLLoader.setClassLoader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
/**
    * This is the method JavaFX calls to start the program.
    * @param stage the equivalent to a JFrame in Swing, but created by JavaFX
    */
@Override
public void start(Stage stage) throws Exception {
    //Tell javafx to use the main_window.fxml file
	FXMLLoader loader = new FXMLLoader(getClass().getResource("main_window.fxml"));
	loader.setClassLoader(getClass().getClassLoader());
	Parent root = loader.load();

	controller = loader.getController();

	stage.setScene(new Scene(root, 1100, 985));
	stage.setTitle("Scribble");
	stage.setResizable(false);
	stage.show();

	hasStarted = true;

	//Test code
	String[] names = {"Billy", "Veronica", "José", "Trista"};
	setPlayerNames(names);
	setPlayer1Score(1);
	setPlayer2Score(10000);
	setPlayer3Score(9001);
	setPlayer4Score(1337);
}
 
开发者ID:RyanCPeters,项目名称:EC_GroupProj_CSC143,代码行数:29,代码来源:FXView.java

示例2: ClickableBitcoinAddress

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:creativechain,项目名称:creacoinj,代码行数:22,代码来源:ClickableBitcoinAddress.java

示例3: viewFor

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
/**
 * Create an instance for a ParametrizedController annotated class.
 */
public static <T> Optional<T> viewFor(Class<T> annotatedClass) {
  ParametrizedController controller = annotatedClass.getAnnotation(ParametrizedController.class);

  if (controller != null) { //NOPMD readability
    try {
      FXMLLoader loader = new FXMLLoader(annotatedClass.getResource(controller.value()));
      loader.setClassLoader(annotatedClass.getClassLoader());
      loader.load();
      return Optional.of(loader.getController());
    } catch (IOException e) {
      throw new RuntimeException("Could not instantiate the FXML controller", e);
    }
  }

  return Optional.empty();
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:20,代码来源:Components.java


注:本文中的javafx.fxml.FXMLLoader.setClassLoader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。