javafx and css code to change hyperlink color on mouse hover


Question

I am working with java fxml application and i have one hyperlink, I want to change its color when mouse is over it and again revert back when mouse is exited from it. Can any body post some code to achieve it. I tried some css code but not working,

On mouse entered:-
 @FXML
    private void changeCloseColorToWhite() {
        hypLnkClose.setStyle("-fx-color: white;");
    }

On mouse exited:-
@FXML
    private void changeCloseColorToBrown() {
        hypLnkClose.setStyle("-fx-color: #606060;");
    }

Thanks in advance.

1
0
10/7/2013 9:30:18 AM

Setting style in java code is heavy on the application. I would suggest defining this in the CSS file. try something like this below to fulfill what you need:

.hyperlink:hover {
    -fx-underline: true;
}
3
11/27/2013 4:36:30 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon