Skip to content
Snippets Groups Projects
Commit eed53267 authored by Tran Peter's avatar Tran Peter
Browse files

fix(ui): fix button getting smaller when moving mouse too quickly #14

parent 0078ea27
No related branches found
No related tags found
4 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development,!4Merge UI into Development
package de.hdm_stuttgart.battlearena.Controller;
import javafx.animation.ScaleTransition;
import javafx.scene.control.Button;
import javafx.scene.control.skin.ButtonSkin;
import javafx.util.Duration;
public class ButtonTransition extends ButtonSkin {
public ButtonTransition(Button button) {
super(button);
// set transition for mouse hovering over button
final ScaleTransition fadeIn = new ScaleTransition(Duration.millis(150));
fadeIn.setNode(button);
fadeIn.setToX(1.1);
fadeIn.setToY(1.1);
button.setOnMouseEntered(e -> fadeIn.playFromStart());
// set transition for mouse exiting buttonButtonTransitionScale
final ScaleTransition fadeOut = new ScaleTransition(Duration.millis(150));
fadeOut.setNode(button);
fadeOut.setToX(1.0);
fadeOut.setToY(1.0);
button.setOnMouseExited(e -> fadeOut.playFromStart());
button.setScaleX(1.0);
button.setScaleY(1.0);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment