开发者

Displaying a string with variables in JavaFX

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜