snehal
snehal

Reputation: 1846

Why JavaFx gives error on width of HBox

I am new learner for JavaFx Technology , I was given the width to HBox in fxml file and it gives me error , Can anyone tell me why this happen ?

 <HBox width="200"></HBox>

Upvotes: 0

Views: 72

Answers (2)

Givver
Givver

Reputation: 473

The attribute width is not valid for HBox. I think the attribute you are looking for is prefWidth as in.

<HBox prefHeight="200" />

If you use JavaFX Scene Builder to create your fxml then it will allow you to do it all graphically and put in all the correct attributes for you.

http://www.oracle.com/technetwork/java/javase/downloads/javafxscenebuilder-info-2157684.html

Hope this helps.

Upvotes: 1

James_D
James_D

Reputation: 209358

Any attribute you use must correspond to a property with a corresponding public set...(...) method. There is no writable property called width (i.e. there is no public setWidth(...) method) defined in HBox. See the Javadocs for the properties and methods that are defined.

Upvotes: 1

Related Questions