本文整理汇总了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();
}
});
}
示例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();
}
示例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();
}
示例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);
}
}
});
}
示例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();
}
}
});
}
示例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);
}
}
});
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例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.");
}
示例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();
}
示例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();
}
}
示例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);
}
}
示例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();
}
}