Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Add image to button in fxml [Solved]

904845Dec 12 2011 — edited Dec 12 2011
I've tried:
        <BorderPane fx:id="bottomContentPane">
            <Button fx:id="preferencesButton" text="Preferences" graphic="@icons/gear.png" />
        </BorderPane>     
but I get
Caused by: java.lang.IllegalArgumentException: Unable to coerce file:/C:/work/JavaFXTest/build/classes/resource/icons/gear.png to class javafx.scene.Node.
	at com.sun.javafx.fxml.BeanAdapter.coerce(Unknown Source)
	at com.sun.javafx.fxml.BeanAdapter.put(Unknown Source)
	at com.sun.javafx.fxml.BeanAdapter.put(Unknown Source)
	at javafx.fxml.FXMLLoader$Element.applyProperty(Unknown Source)
	at javafx.fxml.FXMLLoader$Element.processPropertyAttribute(Unknown Source)
	at javafx.fxml.FXMLLoader$Element.processEndElement(Unknown Source)
I checked and the file does exist.

Edited by: user8790487 on Dec 12, 2011 9:22 AM
code tags

Edited by: user8790487 on Dec 12, 2011 10:23 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 9 2012
Added on Dec 12 2011
3 comments
15,143 views