2

I have a JavaFX GUI in an fxml file with its controller class defined. I have two text items that I want in that GUI, one tied to a variable whose value does not change until the user reloads the screen, the other I would think needs to be a StringProperty as it shows the running total of a column in my TableView. Because of what they are, I'm trying to use Label instead of a TextField as their display control.

I liked Sebastian's answer to this problem here:

Displaying changing values in JavaFx Label

however, when I try to use it I get a compile error that says:

cannot find symbol
   symbol: variable textProperty
   location: variable salesNoLabel of type Label

I'm not sure what I'm doing wrong, but to start with, my label text is initially set in the fxml file, so in my controller I just have its fx:id substituted for "myLabel" listed in Sebastian's answer:

salesNoLabel.textProperty.bind(sn);

where salesNoLabel is the fx:id of the label and sn is a string variable.

Not sure if you need to see more of my code to help me with this problem, but thanks in advance for checking it out.

Community
  • 1
  • 1
John
  • 165
  • 2
  • 3
  • 15

1 Answers1

2

Sebastian's answer had a syntax error, I edited it to fix it.

You need to invoke the textProperty() method on the label:

salesNoLabel.textProperty().bind(sn);    

Note the addition of parentheses after the textProperty identifier to invoke the method.

jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • Cool ... I figured it had to be something simple like that. Works perfectly now ... THANK YOU! – John May 03 '13 at 15:41