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


Java FXMLLoader類代碼示例

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


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

示例1: AboutView

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
/**
 * Creates an instance of a {@link AboutView}.
 *
 * @throws IOException if unable to load the controller
 */
@Inject
public AboutView(final FXMLLoader fxmlLoader) throws UIInitialisationException, IOException {
    stage = new Stage();
    stage.initStyle(StageStyle.UNDECORATED);
    stage.setResizable(false);

    final URL resource = getClass().getResource(ABOUT_VIEW);
    fxmlLoader.setLocation(resource);
    final Scene rootScene = new Scene(fxmlLoader.load());

    rootScene.addEventHandler(KeyEvent.KEY_PRESSED, event -> {
        if (event.getCode() == KeyCode.ESCAPE) {
            stage.hide();
        }
    });

    stage.setScene(rootScene);

    stage.focusedProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue) {
            stage.hide();
        }
    });
}
 
開發者ID:ProgrammingLife2017,項目名稱:hygene,代碼行數:30,代碼來源:AboutView.java

示例2: onStaffModeButtonClicked

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
/**
 * Displays the pop-up dialog which prompts staff members to log in to the system.
 *
 * @throws IOException
 */
@FXML
public void onStaffModeButtonClicked() throws IOException {
    Stage staffLoginDialogStage = new Stage();
    Parent staffLoginDialogRoot = FXMLLoader.load(
        getClass().getResource("/fxml/StaffLoginDialog.fxml")
    );
    Scene staffLoginDialog = new Scene(staffLoginDialogRoot);

    staffLoginDialogStage.getIcons().add(new Image("images/Logo.png"));
    staffLoginDialogStage.setScene(staffLoginDialog);
    staffLoginDialogStage.initModality(Modality.APPLICATION_MODAL);
    staffLoginDialogStage.initOwner(staffModeButton.getScene().getWindow());
    staffLoginDialogStage.setResizable(false);
    staffLoginDialogStage.setTitle("Authentication Required");
    staffLoginDialogStage.centerOnScreen();
    staffLoginDialogStage.show();
}
 
開發者ID:maillouxc,項目名稱:git-rekt,代碼行數:23,代碼來源:HomeScreenController.java

示例3: start

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
@Override
public void start(final Stage stage) throws Exception {
    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    int width = gd.getDisplayMode().getWidth();
    int height = gd.getDisplayMode().getHeight();

    Scene scene = new Scene(FXMLLoader.load(UDEDesktop.class.getResource("resources/UDEDesktopWindow.fxml")), width, height);
    scene.setFill(null);
    scene.getStylesheets().add("resources/stylesheet.css");
    stage.setScene(scene);
    // stage.initStyle(StageStyle.UNDECORATED);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.setTitle("UDEDesktop");
    stage.setMinWidth(300);
    stage.setMinHeight(300);
    stage.show();
    stage.toBack();
}
 
開發者ID:maximstewart,項目名稱:UDE,代碼行數:19,代碼來源:UDEDesktop.java

示例4: openSubmitAction

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
@FXML
public void openSubmitAction(ActionEvent event) throws IOException {
    Node node = (Node) event.getSource();
    final Stage stage = (Stage) node.getScene().getWindow();
    final Parent home = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml"));
    final Scene hScene = new Scene(home);
    Parent root = FXMLLoader.load(getClass().getResource("/fxml/Submit.fxml"));
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();

    root.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            if (ke.getCode() == KeyCode.ESCAPE) {
                System.out.println("Key Pressed: " + ke.getCode());
                stage.setScene(hScene);
            }
        }
    });
}
 
開發者ID:dewarian,項目名稱:FYS_T3,代碼行數:21,代碼來源:submitController.java

示例5: openHelp

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
@FXML
public void openHelp(ActionEvent event) throws IOException {
    Parent root = FXMLLoader.load(getClass().getResource("/fxml/helpPopup.fxml"));
    final Scene scene = new Scene(root);
    final Stage stage = new Stage();
    stage.setTitle("Help");
    stage.setScene(scene);
    stage.show();
    stage.setResizable(false);
    stage.centerOnScreen();

    root.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            if (ke.getCode() == KeyCode.ESCAPE) {
                System.out.println("Key Pressed: " + ke.getCode());
                stage.close();
            }
        }
    });
}
 
開發者ID:dewarian,項目名稱:FYS_T3,代碼行數:21,代碼來源:contactController.java

示例6: openSubmit2

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
@FXML
public void openSubmit2(ActionEvent event) throws IOException {
    Node node = (Node) event.getSource();
    final Stage stage = (Stage) node.getScene().getWindow();
    final Parent home = FXMLLoader.load(getClass().getResource("/fxml/Submit.fxml"));
    final Scene hScene = new Scene(home);
    Parent root = FXMLLoader.load(getClass().getResource("/fxml/Submit2.fxml"));
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();

    root.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            if (ke.getCode() == KeyCode.ESCAPE) {
                System.out.println("Key Pressed: " + ke.getCode());
                stage.setScene(hScene);
            }
        }
    });
}
 
開發者ID:dewarian,項目名稱:FYS_T3,代碼行數:21,代碼來源:submitController.java

示例7: start

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
@Override
public void start(Stage stage) {
	App.stage = stage;
	try {
		Parent root = FXMLLoader.load(App.class.getResource("/ui/Main.fxml"));
		Scene scene = new Scene(root);
		scene.getStylesheets().add(getClass().getResource("/style.css").toExternalForm());
		stage.setTitle("OSRS Data To 317 Converter");		
		stage.centerOnScreen();
		stage.setResizable(false);
		stage.sizeToScene();
		stage.initStyle(StageStyle.UNDECORATED);
		stage.setScene(scene);	
		stage.getIcons().add(new Image(App.class.getResourceAsStream("/icons/icon.png")));
		stage.show();
	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:nshusa,項目名稱:osrs-data-converter,代碼行數:20,代碼來源:App.java

示例8: goToHelp

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
public void goToHelp(double positionX, double positionY) {
	try {
		Stage HelpStage = new Stage();
		Parent root = FXMLLoader.load(getClass().getResource("/view/Help.fxml"));
		Scene scene = new Scene(root,800,550);
		HelpStage.setScene(scene);
		HelpStage.setResizable(false);
		HelpStage.getIcons().add(new Image(getClass().getResourceAsStream("/imges/purse.png")));
		HelpStage.setTitle("Help");
		HelpStage.setX(positionX);
		HelpStage.setY(positionY);
		HelpStage.show();
	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:krHasan,項目名稱:Money-Manager,代碼行數:17,代碼來源:GoToOperation.java

示例9: onEditPriceClickedButton

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
@FXML
private void onEditPriceClickedButton() throws IOException {

    Stage editPriceDialogStage = new Stage();
    Parent editPriceDialogRoot = FXMLLoader.load(
            getClass().getResource("/fxml/EditPriceDialog.fxml")
    );
    service = roomTableView.getSelectionModel().getSelectedItem();
    Scene editPriceDialog = new Scene(editPriceDialogRoot);

    editPriceDialogStage.getIcons().add(new Image("images/Logo.png"));
    editPriceDialogStage.setScene(editPriceDialog);
    editPriceDialogStage.initModality(Modality.APPLICATION_MODAL);
    editPriceDialogStage.initOwner(editPriceButton.getScene().getWindow());
    editPriceDialogStage.setResizable(false);
    editPriceDialogStage.setTitle("Edit Price");
    editPriceDialogStage.centerOnScreen();
    editPriceDialogStage.show();

}
 
開發者ID:maillouxc,項目名稱:git-rekt,代碼行數:21,代碼來源:EditPricesScreenController.java

示例10: start

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
@Override
public void start(Stage stage) {


    FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("view.fxml"));

    GridPane gridPane = null;
    try {
        gridPane = loader.load();
    } catch (IOException e) {
        e.printStackTrace();
    }

    GeneratorController controller = loader.getController();

    Scene scene = new Scene(gridPane, 900, 450);
    stage.setTitle("Generator faktur Dtree");
    stage.setScene(scene);
    stage.setMaxHeight(842.0);
    stage.setMaxWidth(1366.0);
    stage.setResizable(true);
    stage.show();
}
 
開發者ID:Garret29,項目名稱:PDF_Invoice_generator,代碼行數:24,代碼來源:GeneratorView.java

示例11: loadFXML

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
private Parent loadFXML(final View view) {
	try {
		final FXMLLoader loader = new FXMLLoader();
		loader.setLocation(getClass().getResource(view.getFXMLPath()));
		loader.setResources(Client.lang);
		
		// Creating a new instance of the specified controller, controllers never have
		// constructor arguments, therefore this is supposedly fine.
		activeSubViewController = view.getControllerType().newInstance();
		loader.setController(activeSubViewController);
		return loader.load();
	} catch (final IOException | InstantiationException | IllegalAccessException exception) {
		Logging.error("Couldn't load view.", exception);
	}
	
	return new Label("Error loading view.");
}
 
開發者ID:Bios-Marcel,項目名稱:ServerBrowser,代碼行數:18,代碼來源:MainController.java

示例12: start

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception{
    Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
    primaryStage.setTitle("Hello World");
    primaryStage.setScene(new Scene(root, 800, 600));
    primaryStage.setMinHeight(600);
    primaryStage.setMinWidth(800);
    primaryStage.setTitle("Zagadnienie transportowo-produkcyjne");
    primaryStage.show();
}
 
開發者ID:superdurszlak,項目名稱:Transport-Production-Issue,代碼行數:11,代碼來源:Main.java

示例13: setCanvasSize

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
/**
 * 設置canvas大小
 */
private void setCanvasSize() {
    try {
        FXMLLoader fxmlLoader = new FXMLLoader((getClass().getResource("size_chooser.fxml")));
        Parent root1 = fxmlLoader.load();
        Stage stage = new Stage(DECORATED);
        stage.setTitle("選擇畫布");
        Scene scene = new Scene(root1);
        sizeChooser = fxmlLoader.getController();
        stage.setScene(scene);
        stage.showAndWait();
        if (sizeChooser.getCanvas() != null) {
            canvas.setHeight(sizeChooser.getCanvas().getHeight());
            canvas.setWidth(sizeChooser.getCanvas().getWidth());
            canvas.setLayoutX(450 - canvas.getWidth() / 2);
            canvas.setLayoutY(300 - canvas.getHeight() / 2);
            Rectangle rectangle = new Rectangle(canvas.getWidth(), canvas.getHeight());
            rectangle.setLayoutX(canvas.getLayoutX());
            rectangle.setLayoutY(canvas.getLayoutY());
            mainPane.setClip(rectangle);
            GraphicsContext gc = canvas.getGraphicsContext2D();
            gc.setFill(Color.WHITE);
            gc.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());
        } else {
            //不選擇就退出程序
            System.exit(0);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
開發者ID:xfangfang,項目名稱:PhotoScript,代碼行數:34,代碼來源:Controller.java

示例14: mkRoot

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
@Override
public Node mkRoot() {
	try {
		Parent node  = FXMLLoader.load(getClass().getResource("/ComplexScene.fxml"));
		node.setPickOnBounds(true);
		node.setMouseTransparent(true);
		WebView webview = (WebView) node.lookup("webview");
		if(webview != null){
			webview.getEngine().load("http://purecss3.net/doraemon/doraemon_css3.html");
		}

		GesturePane pane = new GesturePane(new SubScene(node, 500, 500));
		VBox.setVgrow(pane, Priority.ALWAYS);
		Label description = new Label("Zoom and scroll on the SubScene below, " +
				                              "observe that controls in JavaFX are vectors " +
				                              "and that lighting effects are respected" +
				                              "(different zoom alters light distance).");
		description.setWrapText(true);
		description.setPadding(new Insets(16));
		return new VBox(description, pane);

	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
開發者ID:tom91136,項目名稱:GestureFX,代碼行數:26,代碼來源:ArbitraryNodeSample.java

示例15: pickPropertyExtract

import javafx.fxml.FXMLLoader; //導入依賴的package包/類
private void pickPropertyExtract() {
	Stage promptWindow = new Stage();
	promptWindow.setTitle("Selection de l'extrait");
	try {
		main.getCurrentMoment().setCurrentProperty(property);
		FXMLLoader loader = new FXMLLoader();
		loader.setLocation(getClass().getResource("/view/SelectDescriptemePart.fxml"));
		loader.setController(new SelectDescriptemePartController(main, promptWindow, new TextArea(),Enregistrement.PROPERTY));
		loader.setResources(main._langBundle);
		BorderPane layout = (BorderPane) loader.load();
		Scene launchingScene = new Scene(layout);
		promptWindow.setScene(launchingScene);
		promptWindow.show();

	} catch (IOException e) {
		// TODO Exit Program
		e.printStackTrace();
	}
}
 
開發者ID:coco35700,項目名稱:uPMT,代碼行數:20,代碼來源:TypePropertyRepresentation.java


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