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:aajavafx.VisitorController.java

@FXML
private void handleGoBack(ActionEvent event) {
    try {//from   ww  w  . ja v a2 s .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);
    }
}

From source file:aajavafx.CustomerMedicineController.java

@FXML
private void handleBackButton(ActionEvent event) {
    try {//from w  w  w  . j a v a  2s  . 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);
        stage.setScene(scene);
        stage.show();

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

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

From source file:aajavafx.VisitorController.java

@FXML
private void handleImageButton(ActionEvent event) {
    Node node = (Node) event.getSource();
    Stage stage = (Stage) node.getScene().getWindow();
    FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser);//from w w w.  ja  v a 2s .c  om
    fileChooser.setTitle("Open Resource File");
    imageFile = fileChooser.showOpenDialog(stage);
    if (imageFile != null) {
        try {
            System.out.println("abs path: " + imageFile.getAbsolutePath());
            System.out.println("can oath: " + imageFile.getCanonicalPath());
            FileInputStream fis = new FileInputStream(imageFile.getCanonicalPath());
            Image image = new Image(fis);
            imageView.setImage(image);
        } catch (IOException ie) {
            System.out.println("IO Error: " + ie);
        }
    }

    /*if(file != null) {
    openFile(file);
            
    }*/

}

From source file:com.exalttech.trex.ui.controllers.PacketBuilderHomeController.java

/**
 * Close button click handler// w  w w  . ja va 2  s . c  om
 *
 * @param event
 */
@FXML
public void handleCloseDialog(final MouseEvent event) {
    Node node = (Node) event.getSource();
    Stage stage = (Stage) node.getScene().getWindow();
    stage.hide();
}

From source file:com.exalttech.trex.ui.controllers.PacketBuilderHomeController.java

/**
 * Save button click handler//  w  ww  .  j  a v a  2s. c  o m
 *
 * @param event
 */
@FXML
public void saveProfileBtnClicked(ActionEvent event) {
    if (saveStream()) {
        // close the dialog
        Node node = (Node) event.getSource();
        Stage stage = (Stage) node.getScene().getWindow();
        stage.hide();
    }
}

From source file:aajavafx.Schedule1Controller.java

@FXML
private void handleGoBack(ActionEvent event) {

    try {//from  w  ww . j  a  v a2  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, 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.CustomerController.java

@FXML
private void handleGoBack(ActionEvent event) {
    //labelError.setText(null);
    try {//from ww  w.j av a2  s .co  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:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java

/**
 * Gets a location inside the component. If <code>offset</code> is
 * <code>null</code>, it returns the middle of the component otherwise it
 * adds the offset to the upper left corner.
 *
 * @param comp/*from   w w  w .j  a v a 2s .co  m*/
 *            the component to get the location for
 * @param offset
 *            the offset
 * @throws IllegalArgumentException
 *             if <code>component</code> is null
 * @return the <b>global </b> coordinates of <code>component</code>
 */
private Point getLocation(Node comp, final Point offset) throws IllegalArgumentException {

    Validate.notNull(comp, "component must not be null"); //$NON-NLS-1$

    Scene s = comp.getScene();
    s.getRoot().layout();

    Point2D pos = comp.localToScreen(0, 0);

    double x = pos.getX();
    double y = pos.getY();
    if (offset == null) {
        final Bounds boundsInParent = comp.getBoundsInParent();
        x += boundsInParent.getWidth() / 2;
        y += boundsInParent.getHeight() / 2;
    } else {
        x += offset.x;
        y += offset.y;
    }

    return new Point(Rounding.round(x), Rounding.round(y));
}