English 中文(简体)
Displaying a string with variables in JavaFX
原标题:
  • 时间:2009-12-16 22:16:08
  •  标签:
  • 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.





相关问题
JavaFX with Maven [closed]

I recently started a JavaFX project, and I d like to use Maven as my compiler/deployment tool. Is there a good tutorial or plugin to integrate JavaFX and Maven?

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....

non java-developer question

Just a basic question about Java (haven t really done anything with it personally yet): Is it possible to write a Java program that runs in a web browser (via JRE) on the client machine? Is ...

Pros and Cons of JavaFX and Silverlight [closed]

I know there is already a question about the performance of Flex, JavaFX, and Silverlight. My question is a bit more broad: We are evaluating the merits of JavaFX and Silverlight to serve as the GUI ...

How to simplify SVG code?

Is it possible to simplify / clean up svg code by replacing the use-tags with standard svg elements? Maybe an inkscape plugin? Haven t found anything... Background: I m converting some svgs to javafx ...

Dynamically changing a keyframes time attribute in JavaFX

I am making a game in JavaFX and have implemented a slider for controlling the game speed. I have a simple slider (javafx.scene.control.Slider) and I m binding the time attribute for the gameloop to ...

Migrate Java Applet to what/where?

I am reviewing currently a medium size code base (around 30K LOC) which uses a huge Applet and interfaces with other systems. It s a tool to create custom labels, so we need drag-n-drop and other ...

热门标签