java - JavaFX RippleAnimation over a Button -


i want create rippleanimation, made circle , used scaletransition , put in button using method setgraphic(..);


sample code:

        final circle circle = new circle(3);         circle.setfill(color.color(0, 0, 0, 0.2));         scaletransition scaletransition = new scaletransition(duration.millis(500), circle);         scaletransition.settox(50f);         scaletransition.settoy(50f);         scaletransition.setautoreverse(false);         scaletransition.setcyclecount(1);         button.setgraphic(circle);         button.setonmouseentered(new eventhandler<mouseevent>() {             @override             public void handle(mouseevent event) {                 scaletransition.play();             }         }); ... 

but gets on button:

enter image description here

how can achieve circle doesn't on button?

simply use shape clipping:

rectangle clip = new rectangle(); clip.widthproperty().bind(button.widthproperty()); clip.heightpropety().bind(button.heightproperty());  circle.setclip(clip); 

hope works, cause haven't worked setgraphics() ever. maybe try putting button + circle stackpane achieve same results.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -