Example usage for javafx.scene Node getScene

List of usage examples for javafx.scene Node getScene

Introduction

In this page you can find the example usage for javafx.scene Node getScene.

Prototype

public final Scene getScene() 

Source Link

Usage

From source file:com.eviware.loadui.ui.fx.util.NodeUtils.java

public static Bounds absoluteBoundsOf(Node node) {
    double tX = node.getScene().getWindow().getX() + node.getScene().getX();
    double tY = node.getScene().getWindow().getY() + node.getScene().getY();
    Bounds boundsInScene = node.localToScene(node.getBoundsInLocal());
    return new BoundingBox(boundsInScene.getMinX() + tX, boundsInScene.getMinY() + tY, boundsInScene.getWidth(),
            boundsInScene.getHeight());/*from   w  ww. ja  v a2s.  c  om*/
}

From source file:Main.java

public static void addDraggableNode(final Node node) {

    node.setOnMousePressed((MouseEvent me) -> {
        dragInitialX = me.getSceneX();/*from   www .ja  v a 2  s  .  c  o m*/
        dragInitialY = me.getSceneY();
    });

    node.setOnMouseDragged((MouseEvent me) -> {
        node.getScene().getWindow().setX(me.getScreenX() - dragInitialX);
        node.getScene().getWindow().setY(me.getScreenY() - dragInitialY);
    });
}

From source file:aajavafx.MedicinesController.java

@FXML
private void handleBackButton(ActionEvent event) {
    try {//from ww  w  . j a v a 2 s .  c o  m

        Node node = (Node) event.getSource();
        Stage stage = (Stage) node.getScene().getWindow();

        FXMLLoader loader = new FXMLLoader(getClass().getResource("MainPage.fxml"));
        Parent root = loader.load();

        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();

        System.out.println("You clicked Schedule!");
    } catch (Exception ex) {

        System.out.println("ERROR! " + ex);
    }

}

From source file:pe.edu.system.jcmr.util.UtilidadesFx.java

public void closeWindow(Node node) {

    Stage stage = (Stage) node.getScene().getWindow();
    stage.close();
}

From source file:aajavafx.LoginController.java

@FXML
private void handleButtonLoginAction(ActionEvent event) {

    try {/*  w w w  .ja v  a  2  s. c o m*/

        username_var = userID.getText().toString();
        password_var = passwordID.getText().toString();
        Kripto myKripto = new Kripto();
        System.out.println(myKripto.encrypt(password_var));

        if (saveCredentials.isSelected()) {
            UserCredentials userCred = new UserCredentials(username_var, password_var);
            try (ObjectOutputStream out = new ObjectOutputStream(Files.newOutputStream(savedCredentials))) {
                out.writeObject(userCred);
            } catch (IOException ex) {
                System.out.println("IO Exception: " + ex);
            } catch (Exception ex) {
                System.out.println("Exception: " + ex);
                ;
            }
        }

        //////Check password disabled 

        //  String passwordCypherFromDB = getPassword(username_var);
        //  String passwordFromDB = myKripto.decrypt(passwordCypherFromDB);
        //   if (passwordFromDB.equals(password_var)) {
        Node node = (Node) event.getSource();
        Stage stage = (Stage) node.getScene().getWindow();

        FXMLLoader loader = new FXMLLoader(getClass().getResource("MainPageTab.fxml"));
        Parent root = loader.load();

        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();

        System.out.println("Taking you to next page!");
        //  } else {
        //     outputmessageID.setText("Login failed!!!!");
        // }
    } catch (Exception ex) {
        System.out.println("LOAD PAGE EXCEPTION: " + ex);
    }

    System.out.println("You clicked me!");

}

From source file:pe.edu.system.jcmr.util.UtilidadesFx.java

public void closeWindow(ActionEvent event) {

    Node source = (Node) event.getSource();
    Stage stage = (Stage) source.getScene().getWindow();
    stage.close();/*from  w  ww.  java  2s .co m*/

}

From source file:aajavafx.EmployeeController.java

@FXML
private void handleGoBack(ActionEvent event) {
    //labelError.setText(null);
    try {//from   w  w  w.java2 s .c o  m
        Node node = (Node) event.getSource();
        Stage stage = (Stage) node.getScene().getWindow();
        FXMLLoader loader = new FXMLLoader(getClass().getResource("MainPageTab.fxml"));
        Parent root = loader.load();
        Scene scene = new Scene(root, 879, 599);
        stage.setScene(scene);

        stage.setTitle("Main menu");
        stage.show();

    } catch (Exception ex) {
        Logger.getLogger(MainPageController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:aajavafx.VisitorScheduleController.java

@FXML
private void handleBackButton(ActionEvent event) {
    try {/*  w ww  . java 2s .c  om*/
        Node node = (Node) event.getSource();
        Stage stage = (Stage) node.getScene().getWindow();
        FXMLLoader loader = new FXMLLoader(getClass().getResource("MainPage.fxml"));
        Parent root = loader.load();
        Scene scene = new Scene(root, 879, 599);
        stage.setScene(scene);

        stage.setTitle("Main menu");
        stage.show();

    } catch (Exception ex) {
        Logger.getLogger(MainPageController.class.getName()).log(Level.SEVERE, null, ex);
    }
}