0

I've been trying to apply blur to Vbox in my scene but only blur Vbox so image behind it seems blurry, but when I do this whole Vbox along with its children gets blurred but I don't want this as the components on top of Vbox should be visible to User

Whole Vbox Blurry:

blurry

I want the VBox to only get blurred on its own, and the TextFields on the Vbox along with Lables should stay visible

My code:


package UI.Controllers;

import javafx.embed.swing.SwingFXUtils;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.Rectangle2D;
import javafx.scene.effect.BoxBlur;
import javafx.scene.effect.GaussianBlur;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.image.WritableImage;
import javafx.scene.layout.*;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.net.URL;
import java.nio.Buffer;
import java.util.ResourceBundle;

public class LoginTemp implements Initializable {
    @FXML
    private VBox loginBox;

    public void applyBlur(){
        Image image = new Image("bg2.jepg");
        ImageView imageView = new ImageView(image);
        BoxBlur blur = new BoxBlur(3,3,3);
        loginBox.setEffect(blur);
        BackgroundImage bgImage = new BackgroundImage(imageView.getImage(),BackgroundRepeat.REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT,
                BackgroundSize.DEFAULT);
        loginBox.setBackground(new Background(bgImage));
    }

    @Override
    public void initialize(URL url, ResourceBundle resourceBundle) {
        applyBlur();
    }
}
jewelsea
  • 150,031
  • 14
  • 366
  • 406
qbikle
  • 1
  • 1
  • 1
    if you need to set blur effect all the time to the image then you can blur that image with an image editor such as gimp or ps – Giovanni Contreras Nov 24 '22 at 16:51
  • 1
    Don’t import the awt classes and other unused classes, even though you don’t seem to use them, it is very confusing. – jewelsea Nov 24 '22 at 17:08
  • 1
    Similar [frost effect](https://stackoverflow.com/questions/22622034/frosted-glass-effect-in-javafx) and [transparent pane with non transparent children](https://stackoverflow.com/questions/12717487/how-to-implement-a-transparent-pane-with-non-transparent-children) – jewelsea Nov 24 '22 at 17:11

0 Answers0