A org.uqbar.arena.widgets.Label is a control used to display information.
Label content can be fixed or bindable. To define a static label you should set text property:
// Xtend new Label(editorPanel).text = "Fahrenheit" // Java new Label(editorPanel).setText("Fahrenheit");
Or you can bind a label to a dynamic property of a model
// Xtend new Label(mainPanel) => [ value <=> "kilometers" <- as soon as model changes kilometers property, the label content updates its content ] // Java new Label(mainPanel) // .bindValueToProperty("kilometers");
Remember: to properly configure a label you should define text or value properties. If you define both, value property overrides text property, so it has no sense.
Usually you bind a label against a read-only property (although there's no need to restrict setter methods in the model).
Labels can be also used to show images, binding image property.
See example above: a model has a path property matching an existing image
@Observable class ImageExample { def getImagePath() { "picture.jpg" }
Label binds its image property using a transformer:
override createContents(Panel mainPanel) { new Label(mainPanel) => [ bindImageToProperty("imagePath", [ imagePath | new Image(imagePath) ]) ]
If using Maven and Eclipse, image should be located in a special source folder defined in pom.xml:
<build> <resources> <resource> <directory>src/main/resources</directory> </resource> </resources>
You can see this example for further investigation.