The transition works, but whenever I click on the button that opens a new scene, I get an error. (Below is the error in my files)
at com.example.car/com.example.car.LoginButtonSkin.<init>(LoginButtonSkin.java:10)
at com.example.car/com.example.car.Controller.initialize(Controller.java:60)
/*and*/
at com.example.car/com.example.car.Controller.registerAction(Controller.java:80)
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
loginButton.setSkin(new LoginButtonSkin(loginButton));
}
//this is the code of the skin that I use: (entire) File name is LoginButtonSkin
public class LoginButtonSkin extends ButtonSkin {
public LoginButtonSkin(Button control) {
super(control);
final FadeTransition fadeIn = new FadeTransition(Duration.millis(200));
fadeIn.setNode(control);
fadeIn.setToValue(1);
control.setOnMouseEntered(e -> fadeIn.playFromStart());
final FadeTransition fadeOut = new FadeTransition(Duration.millis(200));
fadeOut.setNode(control);
fadeOut.setToValue(0.5);
control.setOnMouseExited(e -> fadeOut.playFromStart());
control.setOpacity(0.5);
}
}
//this is the other code for the last error: (Controller.java:80) this one is the onAction method for the opening scene whenever the button is clicked:
@FXML
public void registerAction(ActionEvent event) throws IOException {
registerButton.getScene().getWindow().hide();
Stage login = new Stage();
Parent root = FXMLLoader.load(getClass().getResource("RegisterMain.fxml")); <- this
is where the error is shown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Scene scene = new Scene(root);
login.setScene(scene);
login.show();
login.setTitle("Register");
login.setResizable(false);
}
I am new to JavaFX and really want to make some nice transitions. Previous stack overflow questions didn't guide me that far.
P.S. This is my first ever question I am posting on this website.
I really was trying out the mouseEntered and mouseExited events on SceneBuilder. I also have an FXML file. The first scene opens fine it's just that the clicks don't work.