JavaFX: glowing icon button as an eye-catcher

At sLAB we use glowing icon buttons on the dashboard to get the users attention.

These buttons inform the user that there is some waiting work which has to be finished or some incoming messages are waiting.

Here is a little example:

Override
public void start(Stage primaryStage) {
 
    final Image image = new Image(getClass().getResourceAsStream("button.png"));
    final Button button = new Button();
    button.setText("Title");
    button.setGraphic(new ImageView(image));
    button.setContentDisplay(ContentDisplay.TOP);
    button.setTextAlignment(TextAlignment.CENTER);
 
    final Glow glow = new Glow();
    glow.setLevel(0.0);
    button.setEffect(glow);
 
    final Timeline timeline = new Timeline();
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.setAutoReverse(true);
    final KeyValue kv = new KeyValue(glow.levelProperty(), 0.3);
    final KeyFrame kf = new KeyFrame(Duration.millis(700), kv);
    timeline.getKeyFrames().add(kf);
    timeline.play();        
 
    final FlowPane root = new FlowPane();
    root.setPadding(new Insets(10, 10, 10, 10));
    root.getChildren().add(button);
 
    final Scene scene = new Scene(root, 300, 250);
 
    primaryStage.setTitle("Hello Glowing Button!");
    primaryStage.setScene(scene);
    primaryStage.show();
}

Comments