當前位置: 首頁>>代碼示例>>Java>>正文


Java Initializable類代碼示例

本文整理匯總了Java中javafx.fxml.Initializable的典型用法代碼示例。如果您正苦於以下問題:Java Initializable類的具體用法?Java Initializable怎麽用?Java Initializable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Initializable類屬於javafx.fxml包,在下文中一共展示了Initializable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: replaceSceneContent

import javafx.fxml.Initializable; //導入依賴的package包/類
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();
}
 
開發者ID:meltzow,項目名稱:supernovae,代碼行數:18,代碼來源:SupernovaeGame.java

示例2: load

import javafx.fxml.Initializable; //導入依賴的package包/類
public Object load(String url, Class<?> controllerClass) throws IOException {
    InputStream fxmlStream = null;
    try {
        fxmlStream = context.getResource("classpath:" + url).getInputStream();
        Object controller = context.getBean(controllerClass);
        FXMLLoader loader = context.getBean(FXMLLoader.class);
        loader.setController(controller);
        Object fxml =  loader.load(fxmlStream);
        ((Initializable)controller).initialize(null,null);
        return fxml;

    } finally {
        if (fxmlStream != null) {
            fxmlStream.close();
        }
    }
}
 
開發者ID:CowboyJim,項目名稱:mm3Capture,代碼行數:18,代碼來源:SpringFxmlLoader.java

示例3: replaceSceneContent

import javafx.fxml.Initializable; //導入依賴的package包/類
private Initializable replaceSceneContent(String fxml) {
    FXMLLoader loader = new FXMLLoader(getClass().getResource(fxml));

    Parent root;
    try {
        root = loader.load();
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
        return null;
    }

    // replaceSceneContent can be called from a non-GUI thread, runLater makes it work
    Platform.runLater(() -> {
        Scene scene = new Scene(root, WIDTH, HEIGHT);
        stage.setScene(scene);
        stage.sizeToScene();
    });

    return (Initializable) loader.getController();
}
 
開發者ID:Fellesprosjekt-27,項目名稱:fellesprosjekt,代碼行數:22,代碼來源:CalendarApplication.java

示例4: loadUI

import javafx.fxml.Initializable; //導入依賴的package包/類
public static Initializable loadUI(Stage primaryStage) {
	FxmlContent fxmlContent = FxmlLoadUtils.loadFxml("/com/hk/main/mainframe.fxml");
	if (fxmlContent == null) {
		return null;
	}
	final UndecoratorScene undecoratorScene = new UndecoratorScene(primaryStage, fxmlContent.getPane());
	undecoratorScene.setFadeInTransition();
	primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
		@Override
		public void handle(WindowEvent we) {
			undecoratorScene.setFadeOutTransition();
			RabbitConfiguration.destroy();
			RabbitMethodInterceptor.destroy();
			we.consume();   // Do not hide
		}
	});
	primaryStage.setScene(undecoratorScene);
	primaryStage.sizeToScene();
	primaryStage.toFront();
	Undecorator undecorator = undecoratorScene.getUndecorator();
	primaryStage.setMinWidth(undecorator.getMinWidth());
	primaryStage.setMinHeight(undecorator.getMinHeight());
	primaryStage.setMaximized(true);
	primaryStage.show();
	return (Initializable) fxmlContent.getController();
}
 
開發者ID:jiangchanghui,項目名稱:JavaFxClient,代碼行數:27,代碼來源:MainFrameworkController.java

示例5: initView

import javafx.fxml.Initializable; //導入依賴的package包/類
private SceneOverloaded initView(String fxml, final Initializable controller) {
    FXMLLoader fxmlLoader;
    try {
        fxmlLoader = new FXMLLoader(getClass().getResource(fxml));
        fxmlLoader.setControllerFactory(new Callback<Class<?>, Object>() {
            @Override
            public Object call(Class<?> aClass) {
                return controller;
            }
        });
        AnchorPane page = (AnchorPane) fxmlLoader.load();
        SceneOverloaded scene = new SceneOverloaded(page, controller);
        return scene;
    } catch(IOException exception) {
        logger.error(exception.getMessage(), exception);
        return null;
    }
}
 
開發者ID:ZooMMX,項目名稱:Omoikane,代碼行數:19,代碼來源:SpringAnnotatedConfig.java

示例6: renderFxml

import javafx.fxml.Initializable; //導入依賴的package包/類
public static <C extends Initializable, P> Pair<C, P> renderFxml(Class<C> controllerClass) throws IOException {
  String clzName = controllerClass.getSimpleName();
  String suffix = "Controller";
  if (!clzName.endsWith(suffix)) {
    throw new IOException("Class must named like \"xxxController\".");
  } else {
    return renderFxml(clzName.substring(0, clzName.length() - suffix.length()));
  }
}
 
開發者ID:XDean,項目名稱:CSS-Editor-FX,代碼行數:10,代碼來源:Util.java

示例7: setupInitializableControllerCode

import javafx.fxml.Initializable; //導入依賴的package包/類
private void setupInitializableControllerCode(CodeGenerator codeGenerator, ReflectionResolver resolver) {
    if (OsUtils.isNullOrEmpty(codeGenerator.ControllerType)) {
        return;
    }
    Class<?> controllerClass = resolver.resolve(codeGenerator.ControllerType);
    if (controllerClass == null || !Initializable.class.isAssignableFrom(controllerClass)) {
        return;
    }
    codeGenerator.BuildControlsLines.add("_controller.initialize(null, null);");
}
 
開發者ID:ciplogic,項目名稱:Fx2C,代碼行數:11,代碼來源:FxmlGenerator.java

示例8: loadFXML

import javafx.fxml.Initializable; //導入依賴的package包/類
/**
 * Loads FXML file and it's controller.
 * @param filename the given fxml file
 * @param controller the given controller for the FXML file
 * @param rb the given resource bundle
 * @return Panel containing elements from fxml file
 */
private Pane loadFXML(String filename,Initializable controller,ResourceBundle rb) {
    FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setResources(rb);
    if(controller!=null) fxmlLoader.setController(controller);
    Pane pane = null;
    try {
         pane = (Pane) fxmlLoader.load(this.getClass().getResource(filename).openStream());
    } catch (IOException ex) {
        ex.printStackTrace();
        System.err.println(rb.getString("key.error1"));
        //System.exit(-1);
    }
    return pane;
}
 
開發者ID:EuropeanForestInstitute,項目名稱:efiscen,代碼行數:22,代碼來源:FrameController.java

示例9: loadFXML

import javafx.fxml.Initializable; //導入依賴的package包/類
public static Optional<Parent> loadFXML(Initializable clazz, String path, ResourceBundle bundle) {
	FXMLLoader fxmlLoader = new FXMLLoader(clazz.getClass().getResource(path));
	fxmlLoader.setResources(bundle);
   	fxmlLoader.setController(clazz);
	try {
		return Optional.of((Parent)fxmlLoader.load());
	} catch (IOException e) {
		l.error("Failed to open file {}", path, e);
	}
	return Optional.empty();
}
 
開發者ID:Eldelshell,項目名稱:JobHunter,代碼行數:12,代碼來源:JavaFXUtils.java

示例10: replaceSceneContent

import javafx.fxml.Initializable; //導入依賴的package包/類
private Initializable replaceSceneContent(String fxml) throws Exception {
    FXMLLoader loader = new FXMLLoader();
    InputStream in = Login.class.getResourceAsStream(fxml);
    loader.setBuilderFactory(new JavaFXBuilderFactory());
    loader.setLocation(Login.class.getResource(fxml));
    AnchorPane page;
    try {
        page = (AnchorPane) loader.load(in);
    } finally {
        in.close();
    }
    
    // Store the stage width and height in case the user has resized the window
    double stageWidth = stage.getWidth();
    if (!Double.isNaN(stageWidth)) {
        stageWidth -= (stage.getWidth() - stage.getScene().getWidth());
    }
    
    double stageHeight = stage.getHeight();
    if (!Double.isNaN(stageHeight)) {
        stageHeight -= (stage.getHeight() - stage.getScene().getHeight());
    }
    
    Scene scene = new Scene(page);
    if (!Double.isNaN(stageWidth)) {
        page.setPrefWidth(stageWidth);
    }
    if (!Double.isNaN(stageHeight)) {
        page.setPrefHeight(stageHeight);
    }
    
    stage.setScene(scene);
    stage.sizeToScene();
    return (Initializable) loader.getController();
}
 
開發者ID:rulz88,項目名稱:SAST,代碼行數:36,代碼來源:Login.java

示例11: replaceSceneContent

import javafx.fxml.Initializable; //導入依賴的package包/類
/**
 * @param fxml XML scene file to load
 */
private Initializable replaceSceneContent(String fxml) throws Exception {
    FXMLLoader loader = new FXMLLoader();
    loader.setBuilderFactory(new JavaFXBuilderFactory());
    loader.setLocation(Main.class.getResource(fxml));
    GridPane page;
    try (InputStream in = Main.class.getResourceAsStream(fxml)) {
        page = loader.load(in);
    }
    Scene scene = new Scene(page);
    stage.setScene(scene);
    stage.sizeToScene();
    return (Initializable) loader.getController();
}
 
開發者ID:edlf,項目名稱:auto-shot,代碼行數:17,代碼來源:Main.java

示例12: replaceSceneContent

import javafx.fxml.Initializable; //導入依賴的package包/類
/**
 * Replaces one scene with another
 * 
 * @param fxml
 * @return
 * @throws Exception
 */
private Initializable replaceSceneContent(String fxml) throws Exception {

  // Create a loader
  FXMLLoader loader = new FXMLLoader();

  // Stream the fxml resource
  InputStream in = Main.class.getResourceAsStream(fxml);

  // Load the document
  loader.setBuilderFactory(new JavaFXBuilderFactory());
  loader.setLocation(Main.class.getResource(fxml));

  // Page loading
  AnchorPane page;

  // Instantiate the scene
  try {
    page = (AnchorPane) loader.load(in);
  } finally {
    in.close();
  }

  // Setup the scene
  Scene scene = new Scene(page, 800, 600);

  // Sets the scene to the one that was chosen
  stage.setScene(scene);

  // Resize
  stage.sizeToScene();

  // Returns the instantiated scene
  return (Initializable) loader.getController();
}
 
開發者ID:dinder-mufflin,項目名稱:igtv,代碼行數:42,代碼來源:Main.java

示例13: getController

import javafx.fxml.Initializable; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public <T extends Initializable> T getController() {
    return (T) controller;
}
 
開發者ID:Waverunner,項目名稱:DevLaunch,代碼行數:5,代碼來源:ApplicationDialog.java

示例14: SceneOverloaded

import javafx.fxml.Initializable; //導入依賴的package包/類
public SceneOverloaded(Parent parent, Initializable controller) {
    super(parent);
    setController(controller);
}
 
開發者ID:ZooMMX,項目名稱:Omoikane,代碼行數:5,代碼來源:SceneOverloaded.java

示例15: getController

import javafx.fxml.Initializable; //導入依賴的package包/類
public Initializable getController() {
    return controller;
}
 
開發者ID:ZooMMX,項目名稱:Omoikane,代碼行數:4,代碼來源:SceneOverloaded.java


注:本文中的javafx.fxml.Initializable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。