开发者

Displaying a string with variables in JavaFX

开发者 https://www.devze.com 2022-12-14 01:08 出处:网络
I have little quiz game I\'ve working on and am tracking correct answers. I have a text object that displays the number of consecutive correct answers. This is the content:

I have little quiz game I've working on and am tracking correct answers. I have a text object that displays the number of consecutive correct answers. This is the content:

content: bind consecutive.toString(); 

What I would like to do is mix that in with some string output like this:

content: "{bind consecutive.toString()} in a row!"

Unfortunately that gives me an error complaining about the bind keyword. Creating some intermediary variable is not much better:

var consec_disp = bind consecutive;
content: "{consec_disp.toString()} in a row!"
开发者_高级运维

Although this compiles it only ever displays "0 in a row!"

Anyone have any ideas?


Have you tried?

content: bind "{consecutive.toString()} in a row!"

Unless I'm horribly mistaken that should solve your problem.


Better yet:

content: bind "{consecutive} in a row!"

{} implies that toString() will be called on the variable.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号