3 Replies Latest reply: Dec 19, 2012 9:54 AM by biochemistry43 RSS

    flash effect in Toggle Buttons

    biochemistry43
      Hi all:

      I try to make an animated effect as in the ToggleButtons event "onMouseEntered"

      My idea is that the shadow of the buttons make a blink effect. While the pointer is over the button, I want the shadow becomes large and then small, then big and then small ...

      I tried doing some testing with this code:
      .
      .
      .
      @FXML private Label label;
          @FXML private ToggleButton boton1;
          @FXML private ToggleButton boton2;
      
      FadeTransition ft = new FadeTransition(Duration.millis(3000), boton1);
      DropShadow ds = new DropShadow();
      Timeline timeLine;
      .
      .
      .
      public void shadowTButtons(MouseEvent evt){
          ds.setColor(Color.web("#13EC0C"));
          ds.setRadius(0.1);
          ds.setSpread(0.6f);
          ds.setOffsetX(0.0f);
          ds.setOffsetY(0.0f);
              
          timeLine= new Timeline();
          timeLine.setCycleCount(Timeline.INDEFINITE);
          timeLine.setAutoReverse(true);
          
          KeyValue keyvalue1 =  new KeyValue(ds.radiusProperty(), 2, Interpolator.EASE_OUT);
          ds.setRadius(20.0);
          KeyValue keyvalue2 =  new KeyValue(ds.radiusProperty(), 2, Interpolator.EASE_OUT);
          
          Duration duration = Duration.millis(10000);
           
          KeyFrame keyframe1 = new KeyFrame(Duration.seconds(0), keyvalue1);
          KeyFrame keyframe2 = new KeyFrame(duration, keyvalue2);
          
           timeLine.getKeyFrames().add(keyframe1);
           timeLine.getKeyFrames().add(keyframe2);
           
           timeLine.play();
           
           boton2.setEffect(ds);
      }
      I'm not saying that the code is consistent. Just say I tried.

      The program "runs" but does absolutely nothing.

      I would appreciate any help. It's my first foray into animation programming and I'm still pretty new to JavaFX.

      Sorry if English is not very good.

      blessings

      Edited by: biochemistry43 on 17/12/2012 01:40 PM