Java Code Examples for javafx.scene.control.Label#setEffect()

The following examples show how to use javafx.scene.control.Label#setEffect() . 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: JaceUIController.java    From jace with GNU General Public License v2.0 8 votes vote down vote up
public void displayNotification(String message) {
    Label oldNotification = currentNotification;
    Label notification = new Label(message);
    currentNotification = notification;
    notification.setEffect(new DropShadow(2.0, Color.BLACK));
    notification.setTextFill(Color.WHITE);
    notification.setBackground(new Background(new BackgroundFill(Color.rgb(0, 0, 80, 0.7), new CornerRadii(5.0), new Insets(-5.0))));
    Application.invokeLater(() -> {
        stackPane.getChildren().remove(oldNotification);
        stackPane.getChildren().add(notification);
    });

    notificationExecutor.schedule(() -> {
        Application.invokeLater(() -> {
            stackPane.getChildren().remove(notification);
        });
    }, 4, TimeUnit.SECONDS);
}
 
Example 2
Source File: Toast.java    From ApkToolPlus with Apache License 2.0 6 votes vote down vote up
public Toast(final String msg) {
    label = new Label(msg);
    String style =  "-fx-background-color:black;" +
            "-fx-background-radius:10;" +
            "-fx-font: 16px \"Microsoft YaHei\";" +
            "-fx-text-fill:white;-fx-padding:10;";
    label.setStyle(style);
    DropShadow dropShadow = new DropShadow();
    dropShadow.setBlurType(BlurType.THREE_PASS_BOX);
    dropShadow.setWidth(40);
    dropShadow.setHeight(40);
    dropShadow.setRadius(19.5);
    dropShadow.setOffsetX(0);
    dropShadow.setOffsetY(00);
    dropShadow.setColor(Color.color(0, 0, 0));
    label.setEffect(dropShadow);
}
 
Example 3
Source File: Utility.java    From jace with GNU General Public License v2.0 5 votes vote down vote up
public static Optional<Label> loadIconLabel(String filename) {
    if (isHeadless) {
        return Optional.empty();
    }
    Image img = loadIcon(filename).get();
    Label label = new Label() {
        @Override
        public boolean equals(Object obj) {
            if (obj instanceof Label) {
                Label l2 = (Label) obj;
                return super.equals(l2) || l2.getText().equals(getText());
            } else {
                return super.equals(obj);
            }
        }

        @Override
        public int hashCode() {
            return getText().hashCode();
        }
    };
    label.setGraphic(new ImageView(img));
    label.setAlignment(Pos.CENTER);
    label.setContentDisplay(ContentDisplay.TOP);
    label.setTextFill(Color.WHITE);
    DropShadow shadow = new DropShadow(5.0, Color.BLACK);
    label.setEffect(shadow);
    return Optional.of(label);
}
 
Example 4
Source File: OverView.java    From CrazyAlpha with GNU General Public License v2.0 4 votes vote down vote up
public OverView() {
    root = new Pane();
    Game.getInstance().resetMedia();

    GameMap map = Game.getInstance().getMapManager().getCurrentMap();
    ImageView mapIv = new ImageView(map.getMapImage());
    mapIv.setFitWidth(Game.getInstance().getWidth());
    mapIv.setFitHeight(Game.getInstance().getHeight());

    Label nameLbl = new Label("Game Over!");
    nameLbl.setTextFill(Color.WHITESMOKE);
    nameLbl.setFont(Game.getInstance().getResouceManager().getFont("Starcraft", 80));
    nameLbl.setLayoutX(50);
    nameLbl.setLayoutY(50);


    Label scoreLbl = new Label();
    scoreLbl.setTextFill(Color.WHITESMOKE);
    scoreLbl.setFont(Game.getInstance().getResouceManager().getFont("Starcraft", 60));
    scoreLbl.setLayoutX(50);
    scoreLbl.setLayoutY(map.getHeight() - scoreLbl.getHeight() - 140);
    if (Game.getInstance().getScore() > Game.getInstance().getDataManager().getHighestScore()) {
        // 刷新高分记录!
        scoreLbl.setText("New Record: " + Game.getInstance().getScore());
        Game.getInstance().getDataManager().setHighestScore(Game.getInstance().getScore());
    } else
        scoreLbl.setText("Score: " + Game.getInstance().getScore());

    Reflection reflection = new Reflection();
    reflection.setFraction(1.0);
    nameLbl.setEffect(reflection);

    ImageView homeBtn = new ImageView(Game.getInstance().getResouceManager().getControl("btn_home"));
    homeBtn.setFitWidth(165 * 1.5);
    homeBtn.setFitHeight(65 * 1.5);

    homeBtn.setLayoutX(map.getWidth() - homeBtn.getFitWidth() - 20);
    homeBtn.setLayoutY(map.getHeight() - homeBtn.getFitHeight() - 60);
    homeBtn.setEffect(reflection);
    homeBtn.setOnMouseEntered(event -> {
        homeBtn.setEffect(new Glow(0.8));
        Game.getInstance().getButtonOverMusic().play();
    });
    homeBtn.setOnMouseExited(event -> {
        homeBtn.setEffect(reflection);
        Game.getInstance().getButtonOverMusic().stop();
    });
    homeBtn.setOnMousePressed(event -> {
        homeBtn.setEffect(new GaussianBlur());
        Game.getInstance().getButtonClickMusic().play();
    });
    homeBtn.setOnMouseReleased(event -> {
        homeBtn.setEffect(new Glow(0.8));
        Game.getInstance().home();
    });

    root.getChildren().add(mapIv);
    root.getChildren().add(nameLbl);
    root.getChildren().add(scoreLbl);
    root.getChildren().add(homeBtn);

    makeFadeTransition(homeBtn, 2000, 1, 0.7);
    makeFadeTransition(mapIv, 3000, 1, 0.8);
    makeScaleTransition(mapIv, 10000, 0.25, 0.25);
}
 
Example 5
Source File: PauseView.java    From CrazyAlpha with GNU General Public License v2.0 4 votes vote down vote up
public PauseView() {
    root = new Pane();
    Game.getInstance().resetMedia();

    map = Game.getInstance().getMapManager().getCurrentMap();
    mapIv = new ImageView(map.getMapImage());
    mapIv.setFitWidth(Game.getInstance().getWidth());
    mapIv.setFitHeight(Game.getInstance().getHeight());

    nameLbl = new Label("CrazyAlpha!");
    nameLbl.setTextFill(Color.WHITESMOKE);
    nameLbl.setFont(Game.getInstance().getResouceManager().getFont("Starcraft", 120));
    nameLbl.setLayoutX(50);
    nameLbl.setLayoutY(50);

    Reflection reflection1 = new Reflection();
    reflection1.setFraction(1.0);
    nameLbl.setEffect(reflection1);

    Reflection reflection02 = new Reflection();
    reflection02.setFraction(0.4);

    resumeBtn = new ImageView(Game.getInstance().getResouceManager().getControl("btn_resume"));
    resumeBtn.setFitWidth(165 * 1.5);
    resumeBtn.setFitHeight(65 * 1.5);
    exitBtn = new ImageView(Game.getInstance().getResouceManager().getControl("btn_exit"));
    exitBtn.setFitWidth(165 * 1.5);
    exitBtn.setFitHeight(65 * 1.5);

    resumeBtn.setLayoutX(map.getWidth() - resumeBtn.getFitWidth() - 20);
    resumeBtn.setLayoutY(map.getHeight() - resumeBtn.getFitHeight() - exitBtn.getFitHeight() - 120);
    resumeBtn.setEffect(reflection02);
    resumeBtn.setOnMouseEntered(event -> {
        resumeBtn.setEffect(new Glow(0.8));
        Game.getInstance().getButtonOverMusic().play();
    });
    resumeBtn.setOnMouseExited(event -> {
        resumeBtn.setEffect(reflection02);
        Game.getInstance().getButtonClickMusic().stop();
    });
    resumeBtn.setOnMousePressed(event -> {
        resumeBtn.setEffect(new GaussianBlur());
        Game.getInstance().getButtonClickMusic().play();
        Game.getInstance().resume();
    });
    resumeBtn.setOnMouseReleased(event -> {
        resumeBtn.setEffect(new Glow(0.8));
    });

    exitBtn.setLayoutX(map.getWidth() - exitBtn.getFitWidth() - 20);
    exitBtn.setLayoutY(map.getHeight() - exitBtn.getFitHeight() - 60);
    exitBtn.setEffect(reflection02);
    exitBtn.setOnMouseEntered(event -> {
        exitBtn.setEffect(new Glow(0.8));
        Game.getInstance().getButtonOverMusic().play();
    });
    exitBtn.setOnMouseExited(event -> {
        exitBtn.setEffect(reflection02);
        Game.getInstance().getButtonOverMusic().stop();
    });
    exitBtn.setOnMousePressed(event -> {
        exitBtn.setEffect(new GaussianBlur());
        Game.getInstance().getButtonClickMusic().play();
    });
    exitBtn.setOnMouseReleased(event -> {
        exitBtn.setEffect(new Glow(0.8));
        Game.getInstance().exit();
    });


    root.getChildren().add(mapIv);
    root.getChildren().add(nameLbl);
    root.getChildren().add(resumeBtn);
    root.getChildren().add(exitBtn);

    makeFadeTransition(resumeBtn, 2000, 1, 0.7);
    makeFadeTransition(exitBtn, 2000, 1, 0.7);
    makeFadeTransition(mapIv, 3000, 1, 0.8);
    makeScaleTransition(mapIv, 10000, 0.25, 0.25);
}