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

The following examples show how to use javafx.fxml.FXMLLoader#getController() . 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: InterpolatingLookupPaintScaleSetupDialogFX.java    From mzmine3 with GNU General Public License v2.0 9 votes vote down vote up
public InterpolatingLookupPaintScaleSetupDialogFX(InterpolatingLookupPaintScale paintScale){

        try{

            FXMLLoader root = new FXMLLoader(getClass().getResource("InterpolatingLookupPaintScaleSetupDialogFX.fxml"));
            Parent rootPane = root.load();
            Scene scene = new Scene(rootPane);
            setScene(scene);
            setMinWidth(480);
            setMinHeight(330);

            controller = root.getController();
            controller.addPaintScaleToTableView(paintScale);

        }
        catch (IOException e)
        {
            e.printStackTrace();
        }


    }
 
Example 2
Source File: RemoveTagDialog.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
public RemoveTagDialog(final Node parent, final Collection<String> tags) {
    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    setResizable(true);
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(this.getClass().getResource("SelectEntity.fxml"));
    try {
        getDialogPane().setContent(loader.load());
        SelectEntityController controller = loader.getController();
        controller.setAvaibleOptions(tags);
        setResultConverter(button -> {
            return button == ButtonType.OK
                    ? Tag.Builder.tag(controller.getSelectedOption()).build()
                    : null;
        });
    } catch (IOException e) {
        // TODO update the dialog
        logger.log(Level.WARNING, "Failed to remove tag", e);
    }
}
 
Example 3
Source File: DesignerApplication.java    From OEE-Designer with MIT License 6 votes vote down vote up
HttpSource showHttpServerEditor() throws Exception {
	FXMLLoader loader = FXMLLoaderFactory.httpServerLoader();
	AnchorPane page = (AnchorPane) loader.getRoot();

	// Create the dialog Stage.
	Stage dialogStage = new Stage(StageStyle.DECORATED);
	dialogStage.setTitle(DesignerLocalizer.instance().getLangString("http.servers.title"));
	dialogStage.initModality(Modality.WINDOW_MODAL);
	Scene scene = new Scene(page);
	dialogStage.setScene(scene);

	// get the controller
	HttpServerController httpServerController = loader.getController();
	httpServerController.setDialogStage(dialogStage);
	httpServerController.initializeServer();

	// Show the dialog and wait until the user closes it
	httpServerController.getDialogStage().showAndWait();

	return httpServerController.getSource();
}
 
Example 4
Source File: SketchOnMapSample.java    From arcgis-runtime-samples-java with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage stage) throws IOException {

  // set up the scene
  FXMLLoader loader = new FXMLLoader(getClass().getResource("/sketch_on_map/main.fxml"));
  Parent root = loader.load();
  controller = loader.getController();
  Scene scene = new Scene(root);

  // set up the stage
  stage.setTitle("Sketch on Map Sample");
  stage.setWidth(1000);
  stage.setHeight(700);
  stage.setScene(scene);
  stage.show();
}
 
Example 5
Source File: Main.java    From MythRedisClient with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {

    this.primaryStage = primaryStage;
    this.primaryStage.setTitle("Redis客户端");

    rootLoader = new FXMLLoader();
    rootLoader.setLocation(this.getClass().getResource("/views/MainLayout.fxml"));
    rootLayout = rootLoader.load();

    MainController mainController = rootLoader.getController();
    mainController.setMain(this);

    Scene scene = new Scene(rootLayout);
    this.primaryStage.setScene(scene);
    this.primaryStage.setWidth(1300);
    this.primaryStage.setHeight(700);
    this.primaryStage.setResizable(false);
    this.primaryStage.show();

}
 
Example 6
Source File: GUIController.java    From dctb-utfpr-2018-1 with Apache License 2.0 6 votes vote down vote up
public void showModalRegisterBrand() {
    try {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("modal/Brand.fxml"));
        modalRegisterBrand = loader.load();
        BrandController controller = (BrandController) loader.getController();
        modalScene = new Scene(modalRegisterBrand);
        modalStage.setScene(modalScene);

        controller.setAction("Registrar");
        controller.setContent();
        
        modalStage.show();
     } catch (IOException ex) {
        Logger.getLogger(GUIController.class.getName()).log(Level.SEVERE, null, ex);
     }
}
 
Example 7
Source File: MainController.java    From JavaFX-Tutorial-Codes with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(URL url, ResourceBundle rb) {
    if (!Launcher.isSplashLoaded) {
        loadSplashScreen();
    }

    try {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("/genuinecoder/panel/sidepanel.fxml"));
        VBox box = loader.load();
        SidePanelController controller = loader.getController();
        controller.setCallback(this);
        drawer.setSidePane(box);
    } catch (IOException ex) {
        Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
    }

    HamburgerBackArrowBasicTransition transition = new HamburgerBackArrowBasicTransition(hamburger);
    transition.setRate(-1);
    hamburger.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> {
        transition.setRate(transition.getRate() * -1);
        transition.play();

        if (drawer.isOpened()) {
            drawer.close();
        } else {
            drawer.open();
        }
    });
}
 
Example 8
Source File: ShowPanel.java    From MythRedisClient with Apache License 2.0 5 votes vote down vote up
/** 显示值输入窗口.
 *  @param isNum 是否选择整数类型, true为整数, false为字符串
 */
public boolean showValuePanel(boolean isNum) {
    // 创建 FXMLLoader 对象
    FXMLLoader loader = new FXMLLoader();
    // 加载文件
    loader.setLocation(this.getClass().getResource("/views/ListAddLayout.fxml"));
    AnchorPane pane = null;
    try {
        pane = loader.load();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // 创建对话框
    Stage dialogStage = new Stage();
    dialogStage.setTitle("添加值");
    dialogStage.initModality(Modality.WINDOW_MODAL);
    Scene scene = new Scene(pane);
    dialogStage.setScene(scene);

    controller = loader.getController();
    controller.setDialogStage(dialogStage);
    if (isNum) {
        controller.setTipText("输入0便立即删除\n-1 则永久存活 \n-2 则不存在");
        controller.setFlag("number");
    }

    // 显示对话框, 并等待, 直到用户关闭
    dialogStage.showAndWait();

    return controller.isOkChecked();
}
 
Example 9
Source File: IndexController.java    From xJavaFxTool-spring with Apache License 2.0 5 votes vote down vote up
@FXML
private void pluginManageAction() throws Exception {
    FXMLLoader fXMLLoader = PluginManageController.getFXMLLoader();
    Parent root = fXMLLoader.load();
    PluginManageController pluginManageController = fXMLLoader.getController();
    pluginManageController.setIndexController(this);
    JavaFxViewUtil.openNewWindow(bundle.getString("plugin_manage"), root);
}
 
Example 10
Source File: DefaultCodeGeneratorRunner.java    From tcMenu with Apache License 2.0 5 votes vote down vote up
@Override
public void startCodeGeneration(Stage stage, EmbeddedPlatform platform, String path,
                                List<CodePluginItem> creators, List<String> previousPlugins,
                                boolean modal) {
    try {
        logger.log(INFO, "Starting conversion for [" + platform + "] in path [" + path + "]");
        CodeGenerator gen = platforms.getCodeGeneratorFor(platform, project.getGeneratorOptions());
        if(gen != null) {
            FXMLLoader loader = new FXMLLoader(NewItemDialog.class.getResource("/ui/generatorLog.fxml"));
            BorderPane pane = loader.load();
            CodeGenLoggingController controller = loader.getController();
            controller.init(gen);
            new Thread(() -> {
                gen.startConversion(Paths.get(path), creators, project.getMenuTree(), newNameAndKey(project),
                        previousPlugins, project.getGeneratorOptions().isSaveToSrc());
                Platform.runLater(controller::enableCloseButton);
            }).start();
            createDialogStateAndShow(stage, pane, "Code Generator Log", modal);
        }
        else {
            logger.log(ERROR, "Invalid platform detected: " + platform);
        }
    }
    catch(Exception e) {
        logger.log(ERROR, "Unable to create the form", e);
    }
}
 
Example 11
Source File: MenuController.java    From zest-writer with GNU General Public License v3.0 5 votes vote down vote up
@FXML private void handleOpenButtonAction(ActionEvent event){
    FXMLLoader loader = new CustomFXMLLoader(MainApp.class.getResource("fxml/OpenContent.fxml"));

    Stage dialogStage = new CustomStage(loader, Configuration.getBundle().getString("ui.menu.dialog.content.open.title"));
    dialogStage.setResizable(false);
    OpenContent openContentDialog = loader.getController();
    openContentDialog.setMainApp(mainApp);
    openContentDialog.setOpenContentWindow(dialogStage);

    dialogStage.show();
}
 
Example 12
Source File: WorkScheduleEditorController.java    From OEE-Designer with MIT License 5 votes vote down vote up
@FXML
private void onChooseSchedule() {
	try {
		if (templateController == null) {
			FXMLLoader loader = FXMLLoaderFactory.templateScheduleLoader();
			AnchorPane page = (AnchorPane) loader.getRoot();

			// Create the dialog Stage.
			Stage dialogStage = new Stage(StageStyle.DECORATED);
			dialogStage.setTitle(DesignerLocalizer.instance().getLangString("template.schedule"));
			dialogStage.initModality(Modality.NONE);
			Scene scene = new Scene(page);
			dialogStage.setScene(scene);

			// get the controller
			templateController = loader.getController();
			templateController.setDialogStage(dialogStage);
		}

		// Show the dialog and wait until the user closes it
		templateController.getDialogStage().showAndWait();

		WorkSchedule schedule = templateController.getSelectedSchedule();

		if (schedule != null) {
			PersistenceService.instance().save(schedule);

			displaySchedules();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 13
Source File: MainApp.java    From zest-writer with GNU General Public License v3.0 5 votes vote down vote up
private void showWriter() {
    try {
        FXMLLoader loader = new CustomFXMLLoader(MainApp.class.getResource("fxml/Index.fxml"));
        AnchorPane writerLayout = loader.load();

        rootLayout.setCenter(writerLayout);


        MdTextController controller = loader.getController();
        controller.setMainApp(this);
        index = controller;
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
}
 
Example 14
Source File: MusicPlayer.java    From MusicPlayer with MIT License 5 votes vote down vote up
private static void createLibraryXML() {
    try {
        FXMLLoader loader = new FXMLLoader(MusicPlayer.class.getResource(Resources.FXML + "ImportMusicDialog.fxml"));
        BorderPane importView = loader.load();

        // Create the dialog Stage.
        Stage dialogStage = new Stage();
        dialogStage.setTitle("Music Player Configuration");
        // Forces user to focus on dialog.
        dialogStage.initModality(Modality.WINDOW_MODAL);
        // Sets minimal decorations for dialog.
        dialogStage.initStyle(StageStyle.UTILITY);
        // Prevents the alert from being re-sizable.
        dialogStage.setResizable(false);
        dialogStage.initOwner(stage);

        // Sets the import music dialog scene in the stage.
        dialogStage.setScene(new Scene(importView));

        // Set the dialog into the controller.
        ImportMusicDialogController controller = loader.getController();
        controller.setDialogStage(dialogStage);

        // Show the dialog and wait until the user closes it.
        dialogStage.showAndWait();

        // Checks if the music was imported successfully. Closes the application otherwise.
        boolean musicImported = controller.isMusicImported();
        if (!musicImported) {
            System.exit(0);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 15
Source File: DesignerApplication.java    From OEE-Designer with MIT License 5 votes vote down vote up
void showHttpTrendDialog(EventResolver eventResolver) throws Exception {
	// Load the fxml file and create a new stage for the pop-up dialog.
	FXMLLoader loader = FXMLLoaderFactory.httpTrendLoader();
	AnchorPane page = (AnchorPane) loader.getRoot();

	// Create the dialog Stage.
	Stage dialogStage = new Stage(StageStyle.DECORATED);
	dialogStage.setTitle(DesignerLocalizer.instance().getLangString("http.trend.title"));
	dialogStage.initModality(Modality.NONE);
	Scene scene = new Scene(page);
	dialogStage.setScene(scene);

	// get the controller
	HttpTrendController httpTrendController = loader.getController();
	httpTrendController.setDialogStage(dialogStage);
	httpTrendController.setApp(this);

	// add the trend chart
	SplitPane chartPane = httpTrendController.initializeTrend();

	AnchorPane.setBottomAnchor(chartPane, 50.0);
	AnchorPane.setLeftAnchor(chartPane, 5.0);
	AnchorPane.setRightAnchor(chartPane, 5.0);
	AnchorPane.setTopAnchor(chartPane, 50.0);

	page.getChildren().add(0, chartPane);

	// set the script resolver
	httpTrendController.setScriptResolver(eventResolver);

	// start HTTP server
	httpTrendController.onStartServer();

	// show the trend
	httpTrendController.getDialogStage().show();
}
 
Example 16
Source File: JavafxDisplay.java    From requirementsascode with Apache License 2.0 5 votes vote down vote up
private void loadFXML(String fxmlFileName) {
	try {
		FXMLLoader loader = new FXMLLoader(getClass().getResource(RELATIVE_FXML_PACKAGE_NAME + "/" + fxmlFileName));

		vBox = loader.load();
		controller = (AbstractController) loader.getController();
		controller.setBoundary(boundary);
	} catch (IOException e) {
		e.printStackTrace();
		throw new RuntimeException(e);
	}
}
 
Example 17
Source File: DisplayNavigationView.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
public DisplayNavigationView(AppDescriptor app) {
    this.app = app;
    try {
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(this.getClass().getResource("DisplayNavigationView.fxml"));
        loader.load();
        controller = loader.getController();

        tab = new DockItem(this, loader.getRoot());
        DockPane.getActiveDockPane().addTab(tab);
    } catch (IOException e) {
        DisplayNavigationViewApp.logger.log(Level.WARNING, e.getMessage(), e);
    }
}
 
Example 18
Source File: Archivo.java    From archivo with GNU General Public License v3.0 5 votes vote down vote up
private void initRootLayout() {
    try {
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(Archivo.class.getResource("view/RootLayout.fxml"));
        BorderPane rootLayout = loader.load();

        rootController = loader.getController();
        rootController.setMainApp(this);
        rootController.disableMenuItems();

        Scene scene = new Scene(rootLayout);
        URL styleUrl = getClass().getClassLoader().getResource("resources/style.css");
        if (styleUrl != null) {
            scene.getStylesheets().add(styleUrl.toExternalForm());
        }
        primaryStage.setScene(scene);

        primaryStage.getIcons().addAll(
                new Image(getClass().getClassLoader().getResourceAsStream("resources/archivo-16.png")),
                new Image(getClass().getClassLoader().getResourceAsStream("resources/archivo-32.png")),
                new Image(getClass().getClassLoader().getResourceAsStream("resources/archivo-64.png")),
                new Image(getClass().getClassLoader().getResourceAsStream("resources/archivo-96.png")),
                new Image(getClass().getClassLoader().getResourceAsStream("resources/archivo-128.png")),
                new Image(getClass().getClassLoader().getResourceAsStream("resources/archivo-48.png"))
        );
        primaryStage.show();
    } catch (IOException e) {
        logger.error("Error initializing main window: ", e);
    }
}
 
Example 19
Source File: ZoneOverlay_Stage.java    From Path-of-Leveling with MIT License 4 votes vote down vote up
public ZoneOverlay_Stage(){
    isVisible = false;
    this.setAlwaysOnTop(true);
    this.initStyle(StageStyle.TRANSPARENT);
    
    if(Preferences_Controller.zones_overlay_pos[0] == -200 
            && Preferences_Controller.zones_overlay_pos[1] == -200){
        
        Rectangle2D primScreenBounds = Screen.getPrimary().getVisualBounds();
        primScreenBounds.getMinY();
        prefX = 200.0;
        prefY = primScreenBounds.getMinY();
        
        Preferences_Controller.updateZonesPos(prefX, prefY);
    }else{
        prefX = Preferences_Controller.zones_overlay_pos[0];
        prefY = Preferences_Controller.zones_overlay_pos[1];
    }
    
    this.setOnCloseRequest(event -> {
        System.out.println("Closing application from stage -> level:: ");
        if(saveBuildsToMemory()){
            System.out.println("Successfully saved checkpoint");
        }else{
            System.out.println("Checkpoint save failed");
        }
        System.exit(10);
    });
    if(!Preferences_Controller.zones_toggle){
        FXMLLoader loader = new FXMLLoader(getClass().getResource("/poe/level/fx/overlay/ZoneOverlay.fxml"));
        AnchorPane ap = null;
        try {
            ap = loader.load();
        } catch (IOException ex) {
            Logger.getLogger(ZoneOverlay_Stage.class.getName()).log(Level.SEVERE, null, ex);
        }
        controller = loader.<ZoneOverlay_Controller>getController();
        controller.playTown();
        Scene scene = new Scene(ap);
        scene.getStylesheets().add(getClass().getResource("/styles/style.css").toExternalForm());
        scene.setFill(Color.TRANSPARENT);
        bindKeyEvent(scene);
        this.setScene(scene);
        controller.hookStage(this);
        this.setX(prefX);
        this.setY(prefY);
        fadeIn();
    }
}
 
Example 20
Source File: TVTableApp.java    From examples-javafx-repos1 with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {

    FXMLLoader fxmlLoader = new FXMLLoader( TVTableApp.class.getResource("/tvtable-fxml/TVTable.fxml"));

    Parent p = fxmlLoader.load();

    TVTableController c = fxmlLoader.getController();

    Scene scene = new Scene(p, 1024, 768);
    scene.getStylesheets().add( "css/tvtable.css" );

    primaryStage.setScene( scene );
    primaryStage.setOnShown( (evt) -> c.load() );
    primaryStage.show();
}