Java Code Examples for javafx.fxml.FXMLLoader

The following are top voted examples for showing how to use javafx.fxml.FXMLLoader. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: hygene   File: AboutView.java   Source Code and License 9 votes vote down vote up
/**
 * 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();
        }
    });
}
 
Example 2
Project: FYS_T3   File: submitController.java   Source Code and License 8 votes vote down vote up
@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);
            }
        }
    });
}
 
Example 3
Project: FYS_T3   File: submitController.java   Source Code and License 8 votes vote down vote up
@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);
            }
        }
    });
}
 
Example 4
Project: git-rekt   File: HomeScreenController.java   Source Code and License 7 votes vote down vote up
/**
 * 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();
}
 
Example 5
Project: UDE   File: UDEDesktop.java   Source Code and License 7 votes vote down vote up
@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();
}
 
Example 6
Project: FYS_T3   File: submitController.java   Source Code and License 7 votes vote down vote up
@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();
            }
        }
    });
}
 
Example 7
Project: osrs-data-converter   File: App.java   Source Code and License 7 votes vote down vote up
@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();
	}
}
 
Example 8
Project: Money-Manager   File: GoToOperation.java   Source Code and License 7 votes vote down vote up
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();
	}
}
 
Example 9
Project: eadlsync   File: DiffView.java   Source Code and License 7 votes vote down vote up
public void showDialog() {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/gui/diff/diff-view.fxml"));
    try {
        loader.setController(diffController);
        DialogPane root = loader.load();
        root.getStylesheets().add(getClass().getResource("/gui/diff/diff-view.css").toExternalForm());

        Alert alert = new Alert(Alert.AlertType.WARNING);
        alert.setTitle("Diff Viewer");
        alert.setResizable(true);
        alert.setDialogPane(root);
        alert.initModality(Modality.WINDOW_MODAL);

        Window window = alert.getDialogPane().getScene().getWindow();
        window.setOnCloseRequest(event -> window.hide());

        alert.showAndWait();

    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 10
Project: git-rekt   File: EditPricesScreenController.java   Source Code and License 7 votes vote down vote up
@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();

}
 
Example 11
Project: PDF_Invoice_generator   File: GeneratorView.java   Source Code and License 7 votes vote down vote up
@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();
}
 
Example 12
Project: ServerBrowser   File: MainController.java   Source Code and License 6 votes vote down vote up
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.");
}
 
Example 13
Project: Transport-Production-Issue   File: Main.java   Source Code and License 6 votes vote down vote up
@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();
}
 
Example 14
Project: PhotoScript   File: Controller.java   Source Code and License 6 votes vote down vote up
/**
 * 设置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();
    }
}
 
Example 15
Project: GestureFX   File: ArbitraryNodeSample.java   Source Code and License 6 votes vote down vote up
@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);
	}
}
 
Example 16
Project: uPMT   File: TypePropertyRepresentation.java   Source Code and License 6 votes vote down vote up
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();
	}
}
 
Example 17
Project: fwm   File: TemplateTabController.java   Source Code and License 6 votes vote down vote up
public static TemplateTabController startTemplateTab(Template template, Openable open) throws Exception {
	log.debug("static startNpcTab called.");

	Template ourT = template;
	if(template != null){
		log.debug("ourN got filled from backend");
		template = Backend.getTemplateDao().getFullTemplate(template.getID());
	}else
	{
		ourT = new Template();
		
	}
	
	FXMLLoader loader = new FXMLLoader();
	loader.setLocation(TemplateTabController.class.getResource("templateTab.fxml"));
	Tab rootLayout = (Tab)loader.load();
	TemplateTabController cr = (TemplateTabController)loader.getController();
	cr.start(rootLayout, ourT, open);
	return cr;
}
 
Example 18
Project: QuickNote_Plus   File: main.java   Source Code and License 6 votes vote down vote up
@Override
public void start(Stage primaryStage) {
	try {
		AnchorPane root = (AnchorPane)FXMLLoader.load(getClass().getResource("LogInScreen.fxml")); 
		Scene scene = new Scene(root, 340, 370);
	    scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
		primaryStage.setTitle("QuickNote Plus - Log in");
		primaryStage.setScene(scene);
		primaryStage.setResizable(false);
		primaryStage.show();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 19
Project: marathonv5   File: UnitedStatesMapPane.java   Source Code and License 6 votes vote down vote up
public UnitedStatesMapPane() {
    getStyleClass().add("map-pane");
    setMinSize(USE_PREF_SIZE, USE_PREF_SIZE);
    setPrefHeight(450);
    setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    
    liveMap.setId("liveMap");
    liveMap.setManaged(false);
        liveMap.setCache(true);
        liveMap.setCacheHint(CacheHint.SCALE);
    getChildren().add(liveMap);
    overlayGroup.setId("overlay");
    
    // setip map transforms
    liveMap.getTransforms().setAll(mapPreTranslate, mapScale, mapPostTranslate);
    // load map fxml
    try {
        statesGroup = FXMLLoader.load(UnitedStatesMapPane.class.getResource("us-states-map.fxml"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    // set live map children
    liveMap.getChildren().addAll(statesGroup, overlayGroup);
}
 
Example 20
Project: FYS_T3   File: contactController.java   Source Code and License 6 votes vote down vote up
@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();
            }
        }
    });
}
 
Example 21
Project: bestia-palantir   File: MainApplication.java   Source Code and License 6 votes vote down vote up
@Override
public void start(Stage primaryStage) {
	LOG.info("Starting Hello JavaFX and Maven demonstration application");

	try {
		final Parent rootNode = FXMLLoader.load(getClass().getResource(MAIN_FXML));
		final Scene scene = new Scene(rootNode, 400, 200);
		primaryStage.setTitle("Bestia Palantir");
		primaryStage.setScene(scene);
		primaryStage.show();
	} catch (Exception e) {
		LOG.error("Error during startup.", e);
	}
}
 
Example 22
Project: H-Uppaal   File: MessagePresentation.java   Source Code and License 6 votes vote down vote up
public MessagePresentation(final CodeAnalysis.Message message) {
    this.message = message;

    final URL location = this.getClass().getResource("MessagePresentation.fxml");

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

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

        // Initialize
        initializeMessage();
        initializeNearLabel();

    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
 
Example 23
Project: joanne   File: Gallery.java   Source Code and License 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
    XMLManager xml = new XMLManager();
    xml.setEnvConfiguration();
    stage.setMinWidth(600);
    stage.setMinHeight(650);
    Scene scene = new Scene(root);
    
    //Alert a = new Alert(AlertType.ERROR);
   
    scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
    
    stage.getIcons().add(new Image(new URL(getClass().getResource("/gallery/images/iv.png").toExternalForm()).toString(),16,16,true,true));
    stage.setOnCloseRequest(event ->{
        System.exit(0);
    });
    stage.setScene(scene);
    stage.setTitle("Joanne");
    stage.show();

    this.stage = stage;
    if(new File(new EnvVars().getEnvironmentVariable(Environment.USER_HOME)+File.separator+"joanne"+File.separator+"google_drive").exists()){        
        System.out.println(Files.createDirectories(Paths.get(new EnvVars().getEnvironmentVariable(Environment.USER_HOME)+File.separator+"joanne"+File.separator+"google_drive")));
    }
    new File("/tmp/joanne").mkdir();
}
 
Example 24
Project: redisfx   File: RedisFxMain.java   Source Code and License 6 votes vote down vote up
public void start(Stage primaryStage) throws Exception {

        FXMLLoader fxmlLoader = Fx.getFxmlLoader("/fxml/Main.fxml");

        BorderPane mainPane = fxmlLoader.load();
        MainController mainController = fxmlLoader.getController();
        mainController.setPrimaryStage(primaryStage);

        Icons.Logo.setToStage(primaryStage);

        primaryStage.setTitle(I18n.getString("app_title"));
        primaryStage.setScene(new Scene(mainPane));
        primaryStage.setWidth(950);
        primaryStage.setHeight(700);
        primaryStage.show();
    }
 
Example 25
Project: uPMT   File: Main.java   Source Code and License 6 votes vote down vote up
/**
 * Initializes the root layout.
 */
private void initRootLayout() {
    try {
        // Load root layout from fxml file.
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(getClass().getResource("/view/RootLayout.fxml"));
        loader.setResources(ResourceBundle.getBundle("bundles.Lang",new Locale("en", "EN")));
        this.rootLayoutController = new RootLayoutController(this, primaryStage);
        loader.setController(rootLayoutController);
        loader.setResources(get_langBundle());
        rootLayout = (BorderPane) loader.load();
        // Show the scene containing the root layout.
        Scene scene = new Scene(rootLayout);
        
        primaryStage.setScene(scene);
        primaryStage.setMaximized(true);
        primaryStage.show();
        
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 26
Project: Sifon-Industries   File: Calc.java   Source Code and License 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
	Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

	Scene scene = new Scene(root);
	

	stage.setScene(scene);
	stage.getIcons().add(new Image("/icon.png"));
	stage.show();
	stage.setMinWidth(stage.getWidth());
	stage.setMinHeight(stage.getHeight());

	scene.setOnKeyPressed(e -> {
	    if (e.getCode() == KeyCode.NUMPAD1 || e.getCode() == KeyCode.DIGIT1) {
	        controller.keyPressed('1');
	    }else if (e.getCode() == KeyCode.NUMPAD2 || e.getCode() == KeyCode.DIGIT2) {
	        controller.keyPressed('2');
	    }else if (e.getCode() == KeyCode.NUMPAD3 || e.getCode() == KeyCode.DIGIT3) {
	        controller.keyPressed('3');
	    }else if (e.getCode() == KeyCode.NUMPAD4 || e.getCode() == KeyCode.DIGIT4) {
	        controller.keyPressed('4');
	    }else if (e.getCode() == KeyCode.NUMPAD5 || e.getCode() == KeyCode.DIGIT5) {
	        controller.keyPressed('5');
	    }else if (e.getCode() == KeyCode.NUMPAD6 || e.getCode() == KeyCode.DIGIT6) {
	        controller.keyPressed('6');
	    }else if (e.getCode() == KeyCode.NUMPAD7 || e.getCode() == KeyCode.DIGIT7) {
	        controller.keyPressed('7');
	    }else if (e.getCode() == KeyCode.NUMPAD8 || e.getCode() == KeyCode.DIGIT8) {
	        controller.keyPressed('8');
	    }else if (e.getCode() == KeyCode.NUMPAD9 || e.getCode() == KeyCode.DIGIT9) {
	        controller.keyPressed('9');
	    }else if (e.getCode() == KeyCode.NUMPAD0 || e.getCode() == KeyCode.DIGIT0) {
	        controller.keyPressed('0');
	    }else if (e.getCode() == KeyCode.ADD || e.getCode() == KeyCode.PLUS) {
	        controller.keyPressed('+');
	    }else if (e.getCode() == KeyCode.SUBTRACT || e.getCode() == KeyCode.MINUS) {
	        controller.keyPressed('-');
	    }else if (e.getCode() == KeyCode.MULTIPLY) {
	        controller.keyPressed('*');
	    }else if (e.getCode() == KeyCode.DIVIDE || e.getCode() == KeyCode.SLASH) {
	        controller.keyPressed('/');
	    }else if (e.getCode() == KeyCode.ENTER || e.getCode() == KeyCode.EQUALS) {
	        controller.keyPressed('=');
	    }else if (e.getCode() == KeyCode.PERIOD || e.getCode() == KeyCode.COMMA || e.getCode() == KeyCode.DECIMAL) {
	        controller.keyPressed('.');
	    }else if (e.getCode() == KeyCode.BACK_SPACE) {
	        controller.keyPressed('b');
	    }else if (e.getCode() == KeyCode.ESCAPE || e.getCode() == KeyCode.DELETE) {
	        controller.keyPressed('c');
	    }
	});
}
 
Example 27
Project: FloydWarshallSimulation   File: FXMLDocumentController.java   Source Code and License 6 votes vote down vote up
@FXML
private void nextButtonAction(ActionEvent e) throws IOException{
    value = vertex.getValue();
    
    
    //Will Initialize the number of vertex in targeted classes
    
    TableViewerController.steps = value;
    ManualInputController.steps = value;
    
    AnchorPane temp = null;
    
    if(matrixInput.isSelected())
    {
        temp  = FXMLLoader.load(getClass().getResource("VertexAndEdge.fxml"));
        CategoryChooserController.manualChecker = false;
    }
    
    else
    {
        temp  = FXMLLoader.load(getClass().getResource("ManualInput.fxml"));
        CategoryChooserController.manualChecker = true;
    }
    rootPane.getChildren().setAll(temp);
}
 
Example 28
Project: Dr-Assistant   File: PatientsController.java   Source Code and License 6 votes vote down vote up
private void openPatientHistoryStage(Patient patient) {
    if (patient.getNumberOfPrescription() == 0) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("There is no prescription");
        alert.setHeaderText("History not found");
        alert.setContentText("There is no prescription to show");
        alert.showAndWait();
    } else {
        System.out.println("Go on");
        FXMLLoader fXMLLoader = new FXMLLoader(getClass().getResource("/view/patient/PatientHistory.fxml"));
        try {
            Parent root = fXMLLoader.load();
            PatientHistoryController controller = fXMLLoader.getController();
            controller.setPatient(patient);
            Stage stage = new Stage();
            stage.initModality(Modality.WINDOW_MODAL);
            stage.setTitle(patient.getName() + " History");
            stage.setScene(new Scene(root));
            stage.show();
        } catch (IOException ex) {
            Logger.getLogger(PatientsController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
 
Example 29
Project: DiaEd   File: TemplateView.java   Source Code and License 6 votes vote down vote up
public TemplateView(Store store, DiagramTemplate template) {
    this.store = store;
    this.template = template;

    FXMLLoader fxmlLoader = new FXMLLoader(
            getClass().getResource("/startup/template.fxml")
    );

    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

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

}
 
Example 30
Project: CloneHero   File: App.java   Source Code and License 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    try {
        FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("Menu.fxml"));
        Parent root = loader.load();
        MenuController controller = (MenuController) loader.getController();
        primaryStage.setTitle("Clone Hero");
        primaryStage.setScene(new Scene(root));
        primaryStage.setResizable(false);
        primaryStage.getIcons().add(new Image(getClass().getResource("/icon.png").toString()));
        primaryStage.show();
        controller.start();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 31
Project: Squid   File: SquidUIController.java   Source Code and License 6 votes vote down vote up
private void launchTaskManager() {
    mainPane.getChildren().remove(taskManagerUI);
    try {
        taskManagerUI = FXMLLoader.load(getClass().getResource("TaskManager.fxml"));
        taskManagerUI.setId("TaskManager");
        VBox.setVgrow(taskManagerUI, Priority.ALWAYS);
        HBox.setHgrow(taskManagerUI, Priority.ALWAYS);
        mainPane.getChildren().add(taskManagerUI);
        showUI(taskManagerUI);
        manageRatiosMenu.setDisable(false);
        manageExpressionsMenu.setDisable(false);
        manageReportsMenu.setDisable(false);

    } catch (IOException | RuntimeException iOException) {
        System.out.println("taskManagerUI >>>>   " + iOException.getMessage());
    }
}
 
Example 32
Project: creacoinj   File: ClickableBitcoinAddress.java   Source Code and License 6 votes vote down vote up
public ClickableBitcoinAddress() {
    try {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("bitcoin_address.fxml"));
        loader.setRoot(this);
        loader.setController(this);
        // The following line is supposed to help Scene Builder, although it doesn't seem to be needed for me.
        loader.setClassLoader(getClass().getClassLoader());
        loader.load();

        AwesomeDude.setIcon(copyWidget, AwesomeIcon.COPY);
        Tooltip.install(copyWidget, new Tooltip("Copy address to clipboard"));

        AwesomeDude.setIcon(qrCode, AwesomeIcon.QRCODE);
        Tooltip.install(qrCode, new Tooltip("Show a barcode scannable with a mobile phone for this address"));

        addressStr = convert(address);
        addressLabel.textProperty().bind(addressStr);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example 33
Project: Clash-Royale   File: FXMLC.java   Source Code and License 6 votes vote down vote up
public FXMLC()
{
	FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("NEWHOME.fxml"));
	fxmlLoader.setRoot(this);
	fxmlLoader.setController(this);

	try
	{
		fxmlLoader.load();
	} catch (IOException exception)
	{
		throw new RuntimeException(exception);
	}
	ChoiceBoxInit();
	thread.start();
	System.out.println("thread is active");
}
 
Example 34
Project: Java-9-Programming-Blueprints   File: ConnectToPhoneController.java   Source Code and License 6 votes vote down vote up
public static void showAndWait() {
    try {
        FXMLLoader loader = new FXMLLoader(ConnectToPhoneController.class.getResource("/fxml/connect.fxml"));
        Stage stage = new Stage();
        stage.setScene(new Scene(loader.load()));
        stage.setTitle("Connect to Phone");
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.showAndWait();
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
 
Example 35
Project: GUI-Sorting-Time-Comparison-using-JavaFx   File: ReadDataController.java   Source Code and License 6 votes vote down vote up
@FXML public void automate(ActionEvent event){
	System.out.println("AUTOMATE");
	try{
		((Node)event.getSource()).getScene().getWindow().hide();
		Stage primaryStage = new Stage();
		FXMLLoader loader = new FXMLLoader();
		VBox root = (VBox)loader.load(getClass().getResource("automate.fxml").openStream());
		Scene scene = new Scene(root,200,150);
		primaryStage.setScene(scene);
		primaryStage.setResizable(false);
		primaryStage.setTitle("AUTOMATE");
		primaryStage.show();
	}catch(IOException e){
		System.out.println("IO Exception loading automate.fxml");
		e.printStackTrace();
	}
}
 
Example 36
Project: FYS_T3   File: statisticsController.java   Source Code and License 6 votes vote down vote up
@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();
            }
        }
    });
}
 
Example 37
Project: Clipcon-Client   File: MainScene.java   Source Code and License 6 votes vote down vote up
/** Show progress bar */
public void showProgressBar() {
	Platform.runLater(() -> {
		try {
			Parent toProgressBar = FXMLLoader.load(getClass().getResource("/view/ProgressBar.fxml"));
			Scene scene = new Scene(toProgressBar);
			scene.getStylesheets().add("resources/myprogressbar.css");
			progressBarStage = new Stage();
			
			int progressBarIndex = ProgressBarScene.getIndex();
			
			progressBarStage.initStyle(StageStyle.TRANSPARENT);
			progressBarStage.setScene(scene);
			progressBarStage.getIcons().add(new javafx.scene.image.Image("resources/Logo.png"));
			progressBarStage.initModality(Modality.WINDOW_MODAL);
			progressBarStage.show();
			progressBarStage.setX(Screen.getPrimary().getBounds().getWidth() - progressBarStage.getWidth() - 10);
			progressBarStage.setY(Screen.getPrimary().getBounds().getHeight() - progressBarStage.getHeight() - 50 - progressBarIndex * 55);
			
			progressBarStageArray[progressBarIndex] = progressBarStage;
		} catch (Exception e) {
			e.printStackTrace();
		}
	});
}
 
Example 38
Project: CNU_TermProject_SoftwareEngineering   File: PaymentController.java   Source Code and License 6 votes vote down vote up
private Dialog getPayProgressDialog() {
    try {
        FXMLLoader loader = new FXMLLoader(
                getClass().getResource("/View/PayProgress.fxml")
        );
        Parent root = loader.load();
        dialog = new Dialog();
        dialog.setResizable(false);
        dialog.setDialogPane((DialogPane) root);
        dialog.initOwner(owner);
        dialog.initModality(Modality.WINDOW_MODAL);
        dialog.initStyle(StageStyle.UTILITY);

    } catch (IOException e) {
        System.out.println("Unable to load dialog FXML");
        e.printStackTrace();
    }
    return dialog;
}
 
Example 39
Project: fxexperience2   File: SliderControl.java   Source Code and License 6 votes vote down vote up
private void initialize() {

        final FXMLLoader loader = new FXMLLoader();
        loader.setLocation(SliderControl.class.getResource("/fxml/FXMLSliderControl.fxml")); //NOI18N
        loader.setController(this);
        loader.setRoot(this);
        try {
            loader.load();
        } catch (IOException ex) {
            Logger.getLogger(SliderControl.class.getName()).log(Level.SEVERE, null, ex);
        }

        // when we detect a width change, we know node layout is resolved so we position stop in track
        thumb.widthProperty().addListener((ov, oldValue, newValue) -> {
            if (newValue.doubleValue() > 0) {
             thumbWidth = newValue.doubleValue();
            }
        });
    }
 
Example 40
Project: Hive_Game   File: Main.java   Source Code and License 6 votes vote down vote up
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();
    }
}