Search code examples
javaeclipsegwtwidgetsettext

Increment integer before using as text for widget


I've a weird problem when I try to set the text in GWT Widget (My ide is Eclipse Juno).

Here the case: I've a class with a getter that returns an integer int myClass.getValue(); I want use this value incremented by 1 to set the text in a widget, I've tried in several way without find out a solution:

myWidget.setText(""+1+myClass.getValue());
myWidget.setText(""+(int)(1+myClass.getValue()));
myWidget.setText(Integer.toString(1+myClass.getValue()));
.
.
.

After the compilation in the resulting webapp the text is always""

1value

I'm sure there is a way to do this, but I'm trying from some time and I didn't figured out :(


Solution

  • Try

    myWidgetsetText(Integer.toString(1+getValue()));