Skip to content

This library provides methods to create a dynamically blurred (translucent) stage.

License

Notifications You must be signed in to change notification settings

kieferlam/JavaFX-Blur

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaFX Blur

This library provides methods to apply a blur effect to a JavaFX stage using JNI to call the native window manager functions.

Install

To install, simply add the jar file as a dependency on your favourite IDE (add jar to classpath) and add the library files (.dll) to the library path.

Usage

The module load method should be called at the start of your program to ensure the native functions have been loaded before the external function calls.

public static void main(String[] args){
    Blur.loadBlurLibrary();
    // Launch JavaFX application
}

Once your JavaFX stage is shown, you can call the blur method to apply the blur effect. The stage must be initialised as transparent (StageStyle.TRANSPARENT) or JavaFX will have an opaque window decoration background so the blur effect will not be visible.

You might also need to set the backgrounds of the panes and scenes as transparent/none.

public void start(Stage primaryStage) {
    AnchorPane root = new AnchorPane();
    root.setBackground(Background.EMPTY);
    
    Scene scene = new Scene(root, 640.0, 480.0);
    scene.setFill(Color.TRANSPARENT);

    primaryStage.initStyle(StageStyle.TRANSPARENT);

    primaryStage.setScene(scene);
    primaryStage.show();

    // Blur effect must be called after the stage is visible
    Blur.applyBlur(primaryStage, Blur.ACRYLIC);
}

The second argument of applyBlur(stage, blurType) decides which method of blur should be used. The following blur types are available:

  • TRANSPARENT
    • No blur, the window background is just transparent.
  • BLUR_BEHIND
    • Slight blur behind window (see example image)
  • ACRYLIC
    • Windows acrylic blur. Stronger blur than BLUR_BEHIND.

Compatibility

So far, only the native functions for Windows 10 have been provided.

About

This library provides methods to create a dynamically blurred (translucent) stage.

Resources

License

Stars

Watchers

Forks

Packages

No packages published