Example usage for javafx.scene.layout BackgroundPosition DEFAULT

List of usage examples for javafx.scene.layout BackgroundPosition DEFAULT

Introduction

In this page you can find the example usage for javafx.scene.layout BackgroundPosition DEFAULT.

Prototype

BackgroundPosition DEFAULT

To view the source code for javafx.scene.layout BackgroundPosition DEFAULT.

Click Source Link

Document

The default BackgroundPosition for any BackgroundImage.

Usage

From source file:jp.co.heppokoact.autocapture.FXMLDocumentController.java

/**
 * ???????????/*  w ww.jav a 2  s  .c  o m*/
 * ????????
 * ???ESC????????
 *
 * @return ???????
 * @throws IOException ?????
 */
private Stage createTransparentStage() throws IOException {
    // ??????????
    Stage transparentStage = new Stage(StageStyle.TRANSPARENT);
    transparentStage.initOwner(anchorPane.getScene().getWindow());
    transparentStage.initModality(Modality.APPLICATION_MODAL);
    transparentStage.setResizable(false);
    Rectangle2D rect = Screen.getPrimary().getVisualBounds();
    transparentStage.setWidth(rect.getWidth());
    transparentStage.setHeight(rect.getHeight());

    // ???
    java.awt.Rectangle awtRect = new java.awt.Rectangle((int) rect.getWidth(), (int) rect.getHeight());
    BufferedImage captureImage = robot.createScreenCapture(awtRect);

    // ??????
    ByteArrayInputStream in = ImageUtil.convToInputStream(captureImage);
    BackgroundImage bgImage = new BackgroundImage(new Image(in), BackgroundRepeat.NO_REPEAT,
            BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT);
    Pane pane = new Pane();
    pane.setBackground(new Background(bgImage));
    pane.setStyle("-fx-border-color: rgba(255, 255, 0, 0.5); -fx-border-style: solid; -fx-border-width: 15;");

    // ???ESC?????
    Scene scene = new Scene(pane);
    transparentStage.setScene(scene);
    scene.setOnKeyPressed(e -> {
        if (e.getCode() == KeyCode.ESCAPE) {
            transparentStage.close();
        }
    });

    return transparentStage;
}