0

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.

  • 3
    You omitted important information from the stack trace (e.g., what exception was actually thrown). Please [edit] your question to provide the full stack trace. – Slaw Jul 18 '23 at 02:50
  • 1
    And also would be good if you provide the RegisterMain.fxml and its controller code as well. – Sai Dandem Jul 18 '23 at 03:40
  • See [how to read a StackTrace](https://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors). – jewelsea Jul 18 '23 at 07:14
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jul 18 '23 at 07:31

0 Answers0