javafx.fxml.FXMLLoader Java Examples

The following examples show how to use javafx.fxml.FXMLLoader. 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: WebBrowserController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@FXML
protected void manageHistories() {
    try {
        FXMLLoader fxmlLoader = new FXMLLoader(FxmlStage.class.getResource(
                CommonValues.WebBrowserHistoryFxml), AppVariables.currentBundle);
        Pane pane = fxmlLoader.load();
        Tab tab = new Tab(message("ManageHistories"));
        ImageView tabImage = new ImageView("img/MyBox.png");
        tabImage.setFitWidth(20);
        tabImage.setFitHeight(20);
        tab.setGraphic(tabImage);
        tab.setContent(pane);
        tabPane.getTabs().add(tab);
        tabPane.getSelectionModel().select(tab);

        WebBrowserHistoryController controller = (WebBrowserHistoryController) fxmlLoader.getController();
        controller.parent = this;

    } catch (Exception e) {
        logger.error(e.toString());
    }
}
 
Example #2
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 #3
Source File: Archivo.java    From archivo with GNU General Public License v3.0 6 votes vote down vote up
private void initRecordingList() {
    assert (rootController != null);

    try {
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(Archivo.class.getResource("view/RecordingList.fxml"));

        recordingListController = new RecordingListController(this);
        loader.setController(recordingListController);

        Pane recordingList = loader.load();
        rootController.getMainGrid().add(recordingList, 0, 0);
        rootController.setMenuBindings(recordingListController);

        recordingListController.startTivoSearch();
    } catch (IOException e) {
        logger.error("Error initializing recording list: ", e);
    }
}
 
Example #4
Source File: AboutDialog.java    From BlockMap with MIT License 6 votes vote down vote up
public AboutDialog() throws IOException {
	super(AlertType.NONE, null, ButtonType.CLOSE);
	setTitle("About BlockMap");
	setResizable(true);
	initModality(Modality.APPLICATION_MODAL);

	FXMLLoader loader = new FXMLLoader(getClass().getResource("aboutpane.fxml"));
	loader.setController(this);
	getDialogPane().setContent(loader.load());
	getDialogPane().getStylesheets().add("/de/piegames/blockmap/gui/standalone/about/style.css");

	aboutTitle.setText("BlockMap " + VersionProvider.VERSION);

	@SuppressWarnings("serial")
	List<Dependency> dependencies = new GsonBuilder().registerTypeAdapterFactory(new GsonJava8TypeAdapterFactory()).create().fromJson(
			// TODO automate copying that file on dependency change
			new InputStreamReader(getClass().getResourceAsStream("licenseReport.json")),
			new TypeToken<List<Dependency>>() {
			}.getType());

	for (Dependency dependency : dependencies) {
		this.dependencies.getChildren().add(new DependencyPane(dependency));
	}

	license.setText(LICENSE_TEXT);
}
 
Example #5
Source File: RootLayout.java    From java_fx_node_link_demo with The Unlicense 6 votes vote down vote up
public RootLayout() {
	
	FXMLLoader fxmlLoader = new FXMLLoader(
			getClass().getResource("/RootLayout.fxml")
			);
	
	fxmlLoader.setRoot(this); 
	fxmlLoader.setController(this);
	
	try { 
		fxmlLoader.load();
       
	} catch (IOException exception) {
	    throw new RuntimeException(exception);
	}
}
 
Example #6
Source File: OrbitTheCameraAroundAnObjectSample.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("/orbit_the_camera_around_an_object/main.fxml"));
  Parent root = loader.load();
  controller = loader.getController();
  Scene scene = new Scene(root);

  // set up the stage
  stage.setTitle("Orbit the Camera Around an Object Sample");
  stage.setWidth(800);
  stage.setHeight(700);
  stage.setScene(scene);
  stage.show();
}
 
Example #7
Source File: EventLogController.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Stage createStage(Stage mainStage) {
    FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("event-log"));
    loader.setController(this);

    final Stage dialog = new Stage();
    dialog.initOwner(mainStage.getScene().getWindow());
    dialog.initModality(Modality.NONE);

    Parent root;
    try {
        root = loader.load();
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }

    Scene scene = new Scene(root);
    dialog.setScene(scene);
    return dialog;
}
 
Example #8
Source File: PlayModeView.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
public PlayModeView() {
	FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/PlayModeView.fxml"));
	fxmlLoader.setRoot(this);
	fxmlLoader.setController(this);

	try {
		fxmlLoader.load();
	} catch (IOException exception) {
		throw new RuntimeException(exception);
	}

	boardView = new GameBoardView();
	// setCenter(boardView);
	loadingView = new LoadingBoardView();
	setCenter(loadingView);

	actionPromptView = new HumanActionPromptView();
	//sidePane.getChildren().add(actionPromptView);

	backButton.setOnAction(actionEvent -> NotificationProxy.sendNotification(GameNotification.MAIN_MENU));

	sidePane.getChildren().setAll(actionPromptView, navigationPane);
}
 
Example #9
Source File: ViewUtils.java    From ApkToolPlus with Apache License 2.0 6 votes vote down vote up
/**
 * 打开一个新窗口
 *
 * @param fxmlUrl       fxml文件的url
 * @param isShowTitle   是否显示title
 * @return  Stage,如果出现异常返回null
 */
public static Stage newWindow(URL fxmlUrl, boolean isShowTitle){
    try {
        Stage stage = new Stage();
        if (!isShowTitle){
            setNoBroder(stage);
        }
        // 背景透明
        stage.initStyle(StageStyle.TRANSPARENT);
        Parent layout = FXMLLoader.load(fxmlUrl);

        Scene scene = new Scene(layout, Color.TRANSPARENT);
        stage.setScene(scene);

        // 在屏幕中间
        stage.centerOnScreen();

        return stage;
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example #10
Source File: TraceAUtilityNetworkSample.java    From arcgis-runtime-samples-java with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {

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

  // set title, size and add scene to stage
  stage.setTitle("Trace a Utility Network Sample");
  stage.setWidth(800);
  stage.setHeight(700);
  stage.setScene(scene);
  stage.show();
}
 
Example #11
Source File: MenuControllerApp.java    From tcMenu with Apache License 2.0 6 votes vote down vote up
private RemoteMenuController showConfigChooser(MenuTree tree) throws Exception {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/remoteSelector.fxml"));
    BorderPane pane = loader.load();
    RemoteSelectorController controller = loader.getController();
    controller.init(tree);

    Stage dialogStage = new Stage();
    dialogStage.getIcons().add(new Image(getClass().getResourceAsStream("/controller-icon.png")));
    dialogStage.setTitle("Connect to tcMenu device");
    dialogStage.initModality(Modality.WINDOW_MODAL);
    dialogStage.initOwner(null);
    Scene scene = new Scene(pane);
    dialogStage.setScene(scene);
    dialogStage.showAndWait();
    return controller.getResult();
}
 
Example #12
Source File: Main.java    From devcoretalk with GNU General Public License v2.0 6 votes vote down vote up
/** Loads the FXML file with the given name, blurs out the main UI and puts this one on top. */
public <T> OverlayUI<T> overlayUI(String name) {
    try {
        checkGuiThread();
        // Load the UI from disk.
        URL location = GuiUtils.getResource(name);
        FXMLLoader loader = new FXMLLoader(location);
        Pane ui = loader.load();
        T controller = loader.getController();
        OverlayUI<T> pair = new OverlayUI<T>(ui, controller);
        // Auto-magically set the overlayUI member, if it's there.
        try {
            if (controller != null)
                controller.getClass().getField("overlayUI").set(controller, pair);
        } catch (IllegalAccessException | NoSuchFieldException ignored) {
            ignored.printStackTrace();
        }
        pair.show();
        return pair;
    } catch (IOException e) {
        throw new RuntimeException(e);  // Can't happen.
    }
}
 
Example #13
Source File: AddGem_Controller.java    From Path-of-Leveling with MIT License 6 votes vote down vote up
private void fillBox(int whichAct, VBox whichActBox, HashMap<Zone, ArrayList<Gem>> gemHash, ArrayList<Zone> zoneList) {

        for(Zone z : zoneList){
            try {
                FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("questSplitPanel.fxml"));
                AnchorPane con = fxmlLoader.load();

                QuestSplitPanel_Controller controller = fxmlLoader.getController();
                whichActBox.getChildren().add(con);
                controller.load(z, gemHash.get(z), this);
                tablinkers.add(new TabLinker(controller,z, whichAct - 1));
                gemHash.get(z).forEach(gem -> m_gemNames.add(gem.getGemName()));
            } catch (IOException ex) {
                Logger.getLogger(QuestSplitPanel_Controller.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
            }

        }
    }
 
Example #14
Source File: MessageDisplay.java    From xltsearch with Apache License 2.0 6 votes vote down vote up
MessageDisplay() {
    stage.setTitle("Messages");
    stage.getIcons().addAll(new Image(getClass().getResourceAsStream("/icon32.png")),
                            new Image(getClass().getResourceAsStream("/icon22.png")),
                            new Image(getClass().getResourceAsStream("/icon16.png")));
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/message_display.fxml"));
    fxmlLoader.setController(this);
    try {
        Scene scene = new Scene(fxmlLoader.load(), SCENE_WIDTH, SCENE_HEIGHT);
        stage.setScene(scene);
    } catch (Exception ex) {
        DetailedAlert alert = new DetailedAlert(DetailedAlert.AlertType.ERROR);
        alert.setTitle("Error");
        alert.setHeaderText("Exception while loading MessageDisplay");
        alert.setDetailsText(MessageLogger.getStackTrace(ex));
        alert.showAndWait();
    }
}
 
Example #15
Source File: MainProgramSceneController.java    From Hostel-Management-System with MIT License 6 votes vote down vote up
@FXML
private void changePasswordAction(ActionEvent event)
{
    mainTopAnchorPane.setEffect(new BoxBlur());
    passwordStage = new Stage();
    passwordStage.setOnCloseRequest(new EventHandler<WindowEvent>()
    {
        @Override
        public void handle(WindowEvent t)
        {
            mainTopAnchorPane.effectProperty().setValue(null);
        }
    });
    passwordStage.setTitle("Change Password");
    passwordStage.initModality(Modality.APPLICATION_MODAL);
    passwordStage.initStyle(StageStyle.UTILITY);
    passwordStage.setResizable(false);
    try
    {
        Parent passwordParent = FXMLLoader.load(getClass().getResource("changepassword.fxml"));
        passwordStage.setScene(new Scene(passwordParent));
        passwordStage.show();
    } catch (IOException ex)
    {
    }
}
 
Example #16
Source File: CurlyApp.java    From curly with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    applicationWindow = stage;
    Locale locale = Locale.US;
    ApplicationState.getInstance().setResourceBundle(ResourceBundle.getBundle("Bundle", locale));
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/App.fxml"));
    loader.setResources(ApplicationState.getInstance().getResourceBundle());
    loader.load();
    Parent root = loader.getRoot();
    appController = loader.getController();

    Scene scene = new Scene(root);
    scene.getStylesheets().add("/styles/Styles.css");

    stage.setTitle(ApplicationState.getInstance().getResourceBundle().getString(APPLICATION_TITLE));
    stage.setScene(scene);
    stage.show();

    stage.setOnCloseRequest(event -> {
        ConnectionManager.getInstance().shutdown();
        Platform.exit();
        System.exit(0);
    });
}
 
Example #17
Source File: CubicCurveDemo.java    From java_fx_node_link_demo with The Unlicense 5 votes vote down vote up
public CubicCurveDemo () {
	FXMLLoader fxmlLoader = new FXMLLoader(
			getClass().getResource("/CubicCurveDemo.fxml")
			);
	
	fxmlLoader.setRoot(this); 
	fxmlLoader.setController(this);
	
	try { 
		fxmlLoader.load();
       
	} catch (IOException exception) {
	    throw new RuntimeException(exception);
	}		
}
 
Example #18
Source File: ManualZoomDialog.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 */
public ManualZoomDialog(Window parent, XYPlot plot) {

  initOwner(parent);

  setTitle("Manual zoom");

  setGraphic(new ImageView("file:icons/axesicon.png"));

  getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

  xAxis = (NumberAxis) plot.getDomainAxis();
  yAxis = (NumberAxis) plot.getRangeAxis();

  try {
    URL layersDialogFXML = getClass().getResource(DIALOG_FXML);
    FXMLLoader loader = new FXMLLoader(layersDialogFXML);
    loader.setController(this);
    GridPane grid = loader.load();
    getDialogPane().setContent(grid);
  } catch (Exception e) {
    e.printStackTrace();
  }

  final Button btOk = (Button) getDialogPane().lookupButton(ButtonType.OK);
  btOk.addEventFilter(ActionEvent.ACTION, event -> {
    commitChanges(event);
  });

}
 
Example #19
Source File: ExampleFxml.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws IOException {
    Parent root = FXMLLoader.load(getClass().getResource("/form.fxml"));

    Scene scene = new Scene(root, 300, 275);

    stage.setTitle("FXML Welcome");
    stage.setScene(scene);
    stage.show();    }
 
Example #20
Source File: ReadMessageController.java    From HealthPlus with Apache License 2.0 5 votes vote down vote up
public ReadMessageController(AllMessages message, User newSysUser) {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/ReadMessage.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

    this.message = message;
    this.newSysUser = newSysUser;
    
    try {
        fxmlLoader.load();            
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }
}
 
Example #21
Source File: MainApp.java    From rest-client with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("/fxml/Scene.fxml"));
    
    Scene scene = new Scene(root);
    scene.getStylesheets().add("/styles/Styles.css");
    
    stage.setTitle("RESTClient JFX");
    stage.setScene(scene);
    stage.show();
}
 
Example #22
Source File: StudentManagementController.java    From School-Management-System with Apache License 2.0 5 votes vote down vote up
@FXML
void setBtnStudentMnge(ActionEvent event) {
    try {
        AnchorPane studentMgmt = FXMLLoader.load(getClass().getResource(("/sms/view/fxml/ManageStudents.fxml")));
        manageStudents.getChildren().setAll(studentMgmt);
    }catch(IOException e){
        System.out.println(e);
    }
}
 
Example #23
Source File: FXMLMain.java    From javafx-calendar with MIT License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("fullCalendar.fxml"));
    primaryStage.setTitle("Full Calendar FXML Example");
    primaryStage.setScene(new Scene(loader.load()));
    // Get the controller and add the calendar view to it
    Controller controller = loader.getController();
    controller.calendarPane.getChildren().add(new FullCalendarView(YearMonth.now()).getView());
    primaryStage.show();
}
 
Example #24
Source File: HelloWorld.java    From Learn-Java-12-Programming with MIT License 5 votes vote down vote up
public void start5(Stage primaryStage) {
    try {
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(new URL("file:src/main/resources/helloWorld.fxml"));
        Scene scene = loader.load();

        primaryStage.setTitle("Simple form example");
        primaryStage.setScene(scene);
        primaryStage.onCloseRequestProperty()
                .setValue(e -> System.out.println("\nBye! See you later!"));
        primaryStage.show();
    } catch (Exception ex){
        ex.printStackTrace();
    }
}
 
Example #25
Source File: Calculator.java    From dctb-utfpr-2018-1 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("CalculatorFXML.fxml"));
    
    Scene scene = new Scene(root);
    stage.setResizable(false);
    stage.setScene(scene);
    stage.setTitle("Calculator");
    stage.show();
}
 
Example #26
Source File: RegistrationDialog.java    From tcMenu with Apache License 2.0 5 votes vote down vote up
public static void showRegistration(ConfigurationStorage storage, Stage stage, String registerUrl) {
    try {
        FXMLLoader loader = new FXMLLoader(NewItemDialog.class.getResource("/ui/registrationDialog.fxml"));
        BorderPane pane = loader.load();
        RegistrationController controller = loader.getController();
        controller.init(storage, registerUrl);
        createDialogStateAndShow(stage, pane, "Please Register with us", true);
    }
    catch(Exception e) {
        // in this case, just get out of here.
        logger.log(ERROR, "Unable to create the form", e);
    }
}
 
Example #27
Source File: Initialization.java    From trex-stateless-gui with Apache License 2.0 5 votes vote down vote up
public static void initializeFXML(Object object, String resourceName) {
    FXMLLoader fxmlLoader = new FXMLLoader(
            object.getClass().getResource(resourceName)
    );
    fxmlLoader.setRoot(object);
    fxmlLoader.setController(object);
    try {
        fxmlLoader.load();
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }
}
 
Example #28
Source File: EditAndSyncFeaturesSample.java    From arcgis-runtime-samples-java with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws IOException {
  // set up the scene
  FXMLLoader loader = new FXMLLoader(getClass().getResource("/edit_and_sync_features/main.fxml"));
  Parent root = loader.load();
  controller = loader.getController();
  Scene scene = new Scene(root);

  // set up the stage
  stage.setTitle("Edit And Sync Features Sample");
  stage.setWidth(800);
  stage.setHeight(700);
  stage.setScene(scene);
  stage.show();
}
 
Example #29
Source File: CustomizedTreeCell.java    From PeerWasp with MIT License 5 votes vote down vote up
private void showProperties(PathItem item) {
	try {
		FXMLLoader loader = new FXMLLoader();
		loader.setLocation(getClass().getResource(ViewNames.PROPERTIES_VIEW));
		loader.setController(new Properties(getItem()));

		Parent root = loader.load();

		// load UI on Application thread and show window
		Runnable showStage = new Runnable() {
			@Override
			public void run() {
				Scene scene = new Scene(root);
				stage = new Stage();
				stage.setTitle("Properties of "
						+ getItem().getPath().getFileName());
				stage.setScene(scene);
				stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
					@Override
					public void handle(WindowEvent event) {
						stage = null;
					}
				});

				stage.show();
			}
		};

		if (Platform.isFxApplicationThread()) {
			showStage.run();
		} else {
			Platform.runLater(showStage);
		}
	} catch (IOException e) {
		logger.warn("Exception while showing properties.", e);
	}
}
 
Example #30
Source File: NewMessageController.java    From HealthPlus with Apache License 2.0 5 votes vote down vote up
public NewMessageController(User newSysUser) {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/NewMessage.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

    this.newSysUser = newSysUser;
    
    try {
        fxmlLoader.load();            
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }
}