简体   繁体   中英

JavaFX CSS button background with image | no path |

Im getting too much problems with CSS files path finding. So I use this form:

button.setStyle("-fx-background-color: rgb(160,160,220); -fx-background-radius: 50%;");

How to add image background for button, without image overriding text?

By using :

  button.setStyle ("-fx-background-image: url('file:///w:/Task.jpg');");

Typing file:/// is very important to have correct pathfinding. (w:) is hardrive disk. More common to have (c:) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM