dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: How to animate a button with Timeline?

  1. #1
    Join Date
    Nov 2018
    Posts
    1

    How to animate a button with Timeline?

    Hello!

    I want to animate a button. I want to make it change its position after clicking on it. I wrote such code, but it does not work. In this case, no errors appear in the console. The button simply does not respond to pressing.

    Code:
    double stopPosition = 100;
    KeyValue kk2 = new KeyValue(btn.layoutXProperty(), stopPosition, Interpolator.LINEAR);
    KeyFrame kk = new KeyFrame(Duration.millis(5000),kk2);
    Timeline timeline = new Timeline();
    timeline.getKeyFrames().add(kk);
    timeline.setCycleCount(1);
            
            btn.setOnAction(new EventHandler<ActionEvent>() {
                
                @Override
                public void handle(ActionEvent event) {
                    System.out.println("Hello World!");
                    timeline.play();
                }
            });
    What am I doing wrong?

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,791

    Re: How to animate a button with Timeline?

    Can you make a small, complete program that compiles, executes and shows the problem?
    Norm

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)