B4J Question add image to button

ilan

Expert
Licensed User
Longtime User
hi

i want to add an image to a button via designer but i get this error:

Program started.
מאי 07, 2016 11:12:03 PM com.sun.javafx.css.parser.CSSParser term
WARNING: CSS Error parsing '*{-fx-background-size:stretch;-fx-background-position:center;-fx-background-repeat:no-repeat;-fx-background-image:url(file:/C:/ilan/Broken%20HD%20(DELL)/F/B4J%20Projects/Translator/Files/Add-icon.png);-fx-border-color:#000000;
-fx-border-width:0.00;}: Unexpected token 'file:/C:/ilan/Broken%20HD%20' at [1,114]
מאי 07, 2016 11:12:03 PM com.sun.javafx.css.parser.CSSParser term
WARNING: CSS Error parsing '*{-fx-background-size:stretch;-fx-background-position:center;-fx-background-repeat:no-repeat;-fx-background-image:url(file:/C:/ilan/Broken%20HD%20(DELL)/F/B4J%20Projects/Translator/Files/Delete-icon.png);-fx-border-color:#000000;
-fx-border-width:0.00;}: Unexpected token 'file:/C:/ilan/Broken%20HD%20' at [1,114]
 

Daestrum

Expert
Licensed User
Longtime User
After a quick test it looks like you need to add it to files in the designer and assets
imageonbutton.png


Hope this helps.

Oops I uploaded the wrong picture originally. (it was a background not a button)
 
Last edited:
Upvote 0

ilan

Expert
Licensed User
Longtime User
the weird thing is that i can add an image to an imageview but not to a button (even if i choose the same image)
maybe something with the javafx version?
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Odd I had no problem adding an image to a button using the designer.

Didn't realise it was so easy to do, and I never had to write any css. :)
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
The problem is probably because of the parenthesis in the path. Try to move the project to a new folder without parenthesis.

thanx @Erel, moving the folder to a different path (or removing the "()" ) worked, but still i don't understand why it worked on imageviews but not on buttons??

anyway it is now working, thanx
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Upvote 0
Top