ADD::added animations to buttons in login and register screen
This commit is contained in:
@@ -1,14 +1,9 @@
|
|||||||
package greenify.client.controller;
|
package greenify.client.controller;
|
||||||
|
|
||||||
|
import com.sun.javafx.scene.control.skin.ButtonSkin;
|
||||||
import greenify.client.Application;
|
import greenify.client.Application;
|
||||||
import greenify.client.rest.UserService;
|
import greenify.client.rest.UserService;
|
||||||
import javafx.animation.FadeTransition;
|
import javafx.animation.*;
|
||||||
import javafx.animation.Interpolator;
|
|
||||||
import javafx.animation.KeyFrame;
|
|
||||||
import javafx.animation.KeyValue;
|
|
||||||
import javafx.animation.ParallelTransition;
|
|
||||||
import javafx.animation.Timeline;
|
|
||||||
import javafx.animation.TranslateTransition;
|
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
@@ -172,6 +167,8 @@ public class RegisterWindowController {
|
|||||||
addSlideAnimation(1100, passwordField, 300);
|
addSlideAnimation(1100, passwordField, 300);
|
||||||
TimeUnit.MILLISECONDS.sleep(300);
|
TimeUnit.MILLISECONDS.sleep(300);
|
||||||
addSlideAnimation(1100, passwordField2, -420);
|
addSlideAnimation(1100, passwordField2, -420);
|
||||||
|
|
||||||
|
signUpButton.setSkin(new registerButtonSkin(signUpButton));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -613,4 +610,37 @@ public class RegisterWindowController {
|
|||||||
carTravelElectricLabel.getText().replace(" km/Le", ""));
|
carTravelElectricLabel.getText().replace(" km/Le", ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("Duplicates")
|
||||||
|
public class registerButtonSkin extends ButtonSkin {
|
||||||
|
public registerButtonSkin(Button button) {
|
||||||
|
super(button);
|
||||||
|
|
||||||
|
ScaleTransition scaleUp = new ScaleTransition(Duration.millis(140));
|
||||||
|
scaleUp.setToX(1.2);
|
||||||
|
scaleUp.setToY(1.2);
|
||||||
|
scaleUp.setNode(button);
|
||||||
|
button.setOnMouseEntered(e -> scaleUp.playFromStart());
|
||||||
|
|
||||||
|
ScaleTransition scaleMiddleDown = new ScaleTransition(Duration.millis(50));
|
||||||
|
|
||||||
|
scaleMiddleDown.setToX(1.1);
|
||||||
|
scaleMiddleDown.setToY(1.1);
|
||||||
|
scaleMiddleDown.setNode(button);
|
||||||
|
button.setOnMousePressed(e -> scaleMiddleDown.playFromStart());
|
||||||
|
|
||||||
|
ScaleTransition scaleMiddleUp = new ScaleTransition(Duration.millis(50));
|
||||||
|
|
||||||
|
scaleMiddleUp.setToX(1.2);
|
||||||
|
scaleMiddleUp.setToY(1.2);
|
||||||
|
scaleMiddleUp.setNode(button);
|
||||||
|
button.setOnMouseReleased(e -> scaleMiddleUp.playFromStart());
|
||||||
|
|
||||||
|
ScaleTransition scaleDown = new ScaleTransition(Duration.millis(200));
|
||||||
|
scaleDown.setToX(1.0);
|
||||||
|
scaleDown.setToY(1.0);
|
||||||
|
scaleDown.setNode(button);
|
||||||
|
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
package greenify.client.controller;
|
package greenify.client.controller;
|
||||||
|
|
||||||
|
import com.sun.javafx.scene.control.skin.ButtonSkin;
|
||||||
import greenify.client.Application;
|
import greenify.client.Application;
|
||||||
import greenify.client.rest.UserService;
|
import greenify.client.rest.UserService;
|
||||||
|
import javafx.animation.ScaleTransition;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
@@ -12,6 +14,7 @@ import javafx.scene.control.PasswordField;
|
|||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.stage.Window;
|
import javafx.stage.Window;
|
||||||
|
import javafx.util.Duration;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
@@ -36,6 +39,10 @@ public class UserController {
|
|||||||
@FXML
|
@FXML
|
||||||
private Button signUpButton;
|
private Button signUpButton;
|
||||||
|
|
||||||
|
public void initialize() {
|
||||||
|
loginButton.setSkin(new LoginButtonSkin(loginButton));
|
||||||
|
signUpButton.setSkin(new LoginButtonSkin(signUpButton));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Handles when the user clicks on the login button.
|
* Handles when the user clicks on the login button.
|
||||||
* it checks if the username and password fields are filled
|
* it checks if the username and password fields are filled
|
||||||
@@ -142,5 +149,39 @@ public class UserController {
|
|||||||
registerStage.show();
|
registerStage.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("Duplicates")
|
||||||
|
public class LoginButtonSkin extends ButtonSkin {
|
||||||
|
public LoginButtonSkin(Button button) {
|
||||||
|
super(button);
|
||||||
|
ScaleTransition scaleUp = new ScaleTransition(Duration.millis(140));
|
||||||
|
scaleUp.setToX(1.1);
|
||||||
|
scaleUp.setToY(1.1);
|
||||||
|
scaleUp.setNode(button);
|
||||||
|
button.setOnMouseEntered(e -> scaleUp.playFromStart());
|
||||||
|
|
||||||
|
ScaleTransition scaleMiddleDown = new ScaleTransition(Duration.millis(50));
|
||||||
|
scaleMiddleDown.setFromX(1.1);
|
||||||
|
scaleMiddleDown.setFromY(1.1);
|
||||||
|
scaleMiddleDown.setToX(1.05);
|
||||||
|
scaleMiddleDown.setToY(1.05);
|
||||||
|
scaleMiddleDown.setNode(button);
|
||||||
|
button.setOnMousePressed(e -> scaleMiddleDown.playFromStart());
|
||||||
|
|
||||||
|
ScaleTransition scaleMiddleUp = new ScaleTransition(Duration.millis(50));
|
||||||
|
scaleMiddleUp.setFromX(1.05);
|
||||||
|
scaleMiddleUp.setFromY(1.05);
|
||||||
|
scaleMiddleUp.setToX(1.1);
|
||||||
|
scaleMiddleUp.setToY(1.1);
|
||||||
|
scaleMiddleUp.setNode(button);
|
||||||
|
button.setOnMouseReleased(e -> scaleMiddleUp.playFromStart());
|
||||||
|
|
||||||
|
ScaleTransition scaleDown = new ScaleTransition(Duration.millis(200));
|
||||||
|
scaleDown.setToX(1.0);
|
||||||
|
scaleDown.setToY(1.0);
|
||||||
|
scaleDown.setNode(button);
|
||||||
|
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user