Reputation: 28865
I'd like change the state of a JavaFX 1.3 CheckBox
when the user clicks on the label associated with it. The documentation of the Label
control mentions the labelFor
property:
Label is a non-editable text control. A Label is useful for displaying text that is required to fit within a specific space, and thus may need to use ellipses or truncation to size the string to fit. Labels also are useful in that they can have mnemonics which, if used, will send focus to the Control listed as the target of the
labelFor
property.
I've tried the following:
var autoRefreshCheckBox : CheckBox = CheckBox {
...
}
var autoRefreshCheckBoxLabel : Label = Label {
text: "Autorefresh"
labelFor: autoRefreshCheckBox
}
Unfortunately it does not compile:
[WARNING] ...fx:347: cannot find symbol
[WARNING] symbol : variable labelFor
[WARNING] location: class javafx.scene.control.Label
[WARNING] labelFor: autoRefreshCheckBox
[WARNING] ^
Any idea?
Upvotes: 1
Views: 380
Reputation: 26
you can add a text to the checkbox and it handles the onclick event.
var autoRefreshCheckBox : CheckBox = CheckBox {
text: "Autorefresh"
..
}
Upvotes: 1