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


Java FXMLLoader.getController方法代码示例

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


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

示例1: createControlView

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
private void createControlView(TreeMap... treeMaps) {
    Stage stage = new Stage();
    try {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("DataControl.fxml"));
        Parent root = loader.load();
        DataControlController controller = loader.getController();
        for (TreeMap t : treeMaps) {
            addTab(t);
            controller.addData(t);
        }
        Scene scene = new Scene(root);
        stage.setTitle("FxTreeMap Data control view");
        stage.setScene(scene);
    } catch (IOException e) {
        LOG.log(Level.SEVERE, "Exception while loading control view: {0}", e);
    }
    stage.show();
    stage.setX(stage.getX() + DELTA_SCREEN_POSITION);
    stage.setY(stage.getY() + DELTA_SCREEN_POSITION);
}
 
开发者ID:PtitNoony,项目名称:FxTreeMap,代码行数:21,代码来源:SampleViewController.java

示例2: openPackageDetails

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
public static void openPackageDetails(PackageType pkg, List<CrxPackage> packageList, AuthHandler handler) {
    try {
        FXMLLoader loader = new FXMLLoader(EpicApp.class.getResource("/fxml/PackageInfo.fxml"));
        loader.setResources(ApplicationState.getInstance().getResourceBundle());
        loader.load();
        PackageInfoController runnerActivityController = loader.getController();

        Stage popup = new Stage();
        popup.setTitle(pkg.getName() + " (" + pkg.getVersion() + ")");
        popup.setScene(new Scene(loader.getRoot()));
        popup.initModality(Modality.NONE);
        popup.initOwner(applicationWindow);

        runnerActivityController.setAuthHandler(handler);
        runnerActivityController.setPackage(pkg, packageList);

        popup.showAndWait();
    } catch (IOException ex) {
        Logger.getLogger(EpicApp.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:aem-epic-tool,代码行数:22,代码来源:EpicApp.java

示例3: clickItem

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
@FXML
public void clickItem(MouseEvent event) throws IOException
{
    if (event.getClickCount() == 2) {
        stage = (Stage) label.getScene().getWindow();
        FXMLLoader loader = new FXMLLoader(getClass().getResource("/callib/Views/BorrowedDetails.fxml"));
        Stage modal  = new Stage();
        modal.initModality(Modality.APPLICATION_MODAL);
        modal.setScene(
                new Scene((Pane) loader.load())
        );
        modal.setX(stage.getX() + 50);
        modal.setY(stage.getY() + 50);
        BorrowedDetailsController controller = (BorrowedDetailsController) loader.getController();
        controller.initData(table.getSelectionModel().getSelectedItem().getId());
        
        modal.showAndWait();
        this.displayData();
    }
}
 
开发者ID:bartoszgajda55,项目名称:IP1,代码行数:21,代码来源:BorrowedController.java

示例4: showRulesScreen

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
public void showRulesScreen(){
    try {
        // Load person overview.
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(Main.class.getResource("/main/java/view/RulesScreen.fxml"));
        AnchorPane mainAnchor = (AnchorPane) loader.load();
        
        RulesScreenController controller = loader.getController();
        controller.setMainApp(this);
        controller.handleGoalGame();
        
        primaryStage.getScene().setRoot(mainAnchor);
        if(OptionManager.isFullscreen())
            primaryStage.setFullScreen(true);
        else
            primaryStage.setFullScreen(false);

        // Set person overview into the center of root layout.
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Plinz,项目名称:Hive_Game,代码行数:23,代码来源:Main.java

示例5: ProjectPanePresentation

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
public ProjectPanePresentation() {
    final URL location = this.getClass().getResource("ProjectPanePresentation.fxml");

    final FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(location);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

    try {
        fxmlLoader.setRoot(this);
        fxmlLoader.load(location.openStream());

        controller = fxmlLoader.getController();

        initializeRightBorder();
        initializeBackground();
        initializeToolbar();

        initializeToolbarButton(controller.createComponent);

    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
 
开发者ID:ulriknyman,项目名称:H-Uppaal,代码行数:24,代码来源:ProjectPanePresentation.java

示例6: loadFXML

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
/**
 * Loads the given FXML and instantiates the controller associated with it.
 * Typically you should use {@link BaseController#loadFXML(Class, String)} instead.
 * @param fxmlLocation The location of the FXML file to load.
 * @param clazz The class of the controller to instantiate.
 * @return The controller for the given FXML file.
 */
public static <T extends BaseController> T loadFXML(String fxmlLocation, Class<T> clazz) {
    FXMLLoader fxmlLoader = new FXMLLoader(clazz.getResource(fxmlLocation));
    try {
        Parent root = (Parent) fxmlLoader.load();
        T controller = fxmlLoader.getController();
        controller.fxmlRoot = root;
        controller.currentScene = new Scene(root);
        controller.currentScene.getStylesheets().add(GUILauncher.class.getResource("css/style.css").toString());
        return controller;
    }
    catch (Exception exception) {
        displayErrorPopup(exception, "Fatal Error Encountered: ");
        throw new RuntimeException(exception);
    }
}
 
开发者ID:ciphertechsolutions,项目名称:IO,代码行数:23,代码来源:BaseController.java

示例7: start

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception{

    // Create a new database file if one does not currently exist
    DatabaseHelper.createDatabase();

    // Creates the main view of the application
    FXMLLoader root = new FXMLLoader(getClass().getResource("/view/mainTabPane.fxml"));
    primaryStage.setTitle("Recordian");
    primaryStage.setScene(new Scene(root.load()));
    primaryStage.setOnCloseRequest(event -> Platform.exit());
    MainTabPaneController mainTabPaneController = root.getController();
    mainTabPaneController.setCurrentStage(primaryStage);
    primaryStage.show();
}
 
开发者ID:kwilliams3,项目名称:Recordian,代码行数:16,代码来源:Main.java

示例8: setupLogController

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
public static void setupLogController() {
	try {
		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
		URL fxmlUrl = classLoader.getResource("gui/log.fxml");
		if (fxmlUrl == null) {
			OneClientLogging.logger.error("An error has occurred loading instance_creation.fxml!");
			return;
		}
		FXMLLoader fxmlLoader = new FXMLLoader();
		fxmlLoader.setLocation(fxmlUrl);
		fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
		Parent root = fxmlLoader.load(fxmlUrl.openStream());
		stage = new Stage();
		stage.setTitle("One Client - Log");
		stage.getIcons().add(new Image("images/icon.png"));
		stage.setResizable(true);
		stage.setAlwaysOnTop(false);
		stage.initOwner(Main.stage);
		stage.initModality(Modality.NONE);
		Scene scene = new Scene(root, 600, 300);
		scene.getStylesheets().add("gui/css/theme.css");
		stage.setScene(scene);
		logController = fxmlLoader.getController();
		logController.setStage(stage);
		TextAreaAppender.setTextArea(logController.logArea);
	} catch (Exception e) {
		OneClientLogging.error(e);
	}
}
 
开发者ID:HearthProject,项目名称:OneClient,代码行数:30,代码来源:OneClientLogging.java

示例9: start

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
@Override
    public void start(Stage primaryStage) throws Exception{
        FXMLLoader fxmlLoader = new FXMLLoader();
        fxmlLoader.setLocation(getClass().getResource("sample.fxml"));
        Parent root = fxmlLoader.load();
        Screen screen = Screen.getPrimary ();

//        界面初始化
        Controller controller = fxmlLoader.getController();
        controller.init(primaryStage);

        Rectangle2D bounds = screen.getVisualBounds ();

        double minX = bounds.getMinX ();
        double minY = bounds.getMinY ();
        double maxX = bounds.getMaxX ();
        double maxY = bounds.getMaxY ();

        screenWidth = maxX - minX;
        screenHeight = maxY - minY;

        Scene scene = new Scene(root, (maxX - minX) * 0.6, (maxY - minY) * 0.6);

        primaryStage.setTitle ("Higher Cloud Compute Platform");
        primaryStage.setScene (scene);
		primaryStage.setFullScreen(true);
        primaryStage.show ();

    }
 
开发者ID:Luodian,项目名称:Higher-Cloud-Computing-Project,代码行数:30,代码来源:Main.java

示例10: TrackerPaintStage

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
private TrackerPaintStage() {
    FXMLLoader loader = new FXMLLoader(
            getClass().getClassLoader().getResource(
                    "FXML/TrackerPaintScene.fxml"));
    try {
        root = loader.load();
        paintStageController = loader.getController();
    } catch (Exception e) {
        e.printStackTrace();
    }
    this.setTitle("Visualisation options");
    if (root != null) {
        Scene scene = new Scene(root, 1000, 500);
        this.setScene(scene);
    }
}
 
开发者ID:Alanocallaghan,项目名称:qupath-tracking-extension,代码行数:17,代码来源:TrackerPaintStage.java

示例11: openPatientEditStage

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
private void openPatientEditStage(int patientId) {
    FXMLLoader fXMLLoader = new FXMLLoader(getClass().getResource("/view/patient/EditPatient.fxml"));
    try {
        Parent root = fXMLLoader.load();
        EditPatientController controller = fXMLLoader.getController();
        controller.getPatientDetails(patientId);
        Stage stage = new Stage();
        stage.initModality(Modality.WINDOW_MODAL);
        stage.setTitle("Edit Patient");
        stage.setScene(new Scene(root));
        stage.show();

    } catch (IOException ex) {
        Logger.getLogger(PatientsController.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:kmrifat,项目名称:Dr-Assistant,代码行数:17,代码来源:PatientsController.java

示例12: newInstance

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
public static AssocSelectionDialogController newInstance(UIToolBox toolBox) {
    final ResourceBundle bundle = toolBox.getI18nBundle();
    FXMLLoader loader = new FXMLLoader(AssocSelectionDialogController.class
            .getResource("/fxml/AssociationSelectionPane.fxml"), bundle);
    try {
        loader.load();
        return loader.getController();
    }
    catch (Exception e) {
        throw new RuntimeException("Failed to load AssocSelectionPane from FXML", e);
    }
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:13,代码来源:AssocSelectionDialogController.java

示例13: Page

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
public Page(String title, PagePane pagePane) {
        this.setText(title);
        setClosable(true);
        tooltip=new Tooltip();
        tooltip.setText(title);
        tooltip.textProperty().bind(this.textProperty());
        try {
            StackPane headerArea = (StackPane) pagePane.lookup(".tab-header-area");

            URL location = getClass().getResource("/fxml/tab_content.fxml");

            FXMLLoader fxmlLoader = new FXMLLoader();
            fxmlLoader.setLocation(location);
            fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
            Parent parent =  fxmlLoader.load(location.openStream());

//            FXMLLoader fxmlLoader=new FXMLLoader(Res.getFxmlRes("tab_content"));
//            Pane parent=fxmlLoader.load();
            setContent(parent);
            controller=fxmlLoader.getController();
            controller.getHeader().prefWidthProperty().bind(pagePane.widthProperty());
            controller.getContainer().prefWidthProperty().bind(pagePane.widthProperty());
            controller.getContainer().prefHeightProperty().bind(pagePane.heightProperty()
                    .subtract(headerArea.heightProperty())
                    .subtract(controller.getHeader().heightProperty()));
            this.setOnClosed(controller::close);
            controller.setTab(this);
            controller.setPagePane(pagePane);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:whitewoodcity,项目名称:xbrowser,代码行数:33,代码来源:Page.java

示例14: editorButtonAction

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
/**
 * Method to be called on editor button click
 * @param event click event
 */
public void editorButtonAction(ActionEvent event) {
    try {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("/Editor.fxml"));
        Parent root = loader.load();
        editorController = (EditorController) loader.getController();
        fileChooser.setTitle("Select song");
        fileChooser.getExtensionFilters().clear();
        fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("MP3", "*.mp3"));
        File songFile = fileChooser.showOpenDialog(stage);
        if (songFile == null) {
            return;
        }
        Stage editorStage = new Stage();
        editorStage.setTitle("Clone Hero Editor");
        editorStage.setScene(new Scene(root));
        editorStage.setResizable(false);
        editorStage.getIcons().add(new Image(getClass().getResource("/icon.png").toString()));
        editorStage.show();
        editorController.setSongPath(songFile.toURI().toString());

        editorController.start();
        //((Node)(event.getSource())).getScene().getWindow().hide();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:JavaMugs,项目名称:CloneHero,代码行数:31,代码来源:MenuController.java

示例15: showEditQuestionDialog

import javafx.fxml.FXMLLoader; //导入方法依赖的package包/类
public static boolean showEditQuestionDialog(Stage ps,Question question,String title){
	try {
		// Load the fxml file and create a new stage for the popup dialog.
		FXMLLoader loader = new FXMLLoader();
		loader.setLocation(MainApp.class.getResource("view_controller/EditQuestion.fxml"));
		GridPane page = loader.load();

		// Create the dialog Stage.
		Stage dialogStage = new Stage();
		dialogStage.setTitle(title);
		dialogStage.getIcons().add(new Image(MainApp.class.getResourceAsStream("resources/icon.png")));
		dialogStage.initModality(Modality.WINDOW_MODAL);
		dialogStage.initOwner(ps);
		Scene scene = new Scene(page);
		dialogStage.setScene(scene);
		dialogStage.setWidth(450);
		dialogStage.setHeight(700);
		dialogStage.setResizable(false);

		// Set the question into the controller.
		EditQuestionCtrl controller = loader.getController();
		controller.dialogStage = dialogStage;
		controller.setQuestion(question);

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

		return controller.okClicked;
	} catch (IOException e) {
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:eacp,项目名称:Luna-Exam-Builder,代码行数:34,代码来源:MainApp.java


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