2013-10-07 103 views
0

我正在使用java fxml應用程序,我有一個超鏈接,我想在鼠標懸停時更改其顏色,並在鼠標退出時再次恢復。任何機構可以發佈一些代碼來實現它。我試過一些CSS代碼,但不工作,javafx和css代碼來改變鼠標懸停上的超鏈接顏色

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

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

在此先感謝。

+0

http://docs.oracle.com/javafx/2/css_tutorial/jfxpub-css_tutorial.htm – falguni

回答

0
You can also do like this 
your_file.fxml(This is you .fxml file) 
<Hyperlink text="you text to being hyperlink" styleClass="myLink"> 


your_style.css(This is your styleSheet file) 

.myLink{ 
    -fx-text-fill: white; 
     } 
.myLink:hover{ 
    -fx-text-fill: #606060; 
     } 

This will also work fine. So try it 
3

Java代碼中的設置樣式在應用程序中很重。我會建議在CSS文件中定義它。請嘗試下面的內容以滿足您的需求:

.hyperlink:hover { 
    -fx-underline: true; 
}