I'm trying to set an int value using jLabel and the setText method

advertisements

I'm trying to set an int value using jLabel and the setText method. But of course setText wants a String. How do I get round this? I'll give you a snippet of the code:

int value = 1;
if (this.crit.getValue() == 1.0D)
{
  value = 10 - ((int)(1.0D / this.crit.getValue()) + 1);
  this.lblUnten.setText((int)(1.0D / this.crit.getValue())+"");
  texts((int)(1.0D / this.crit.getValue()), this.lblUntenmitte);
}
if ((this.crit.getValue() < 1.0D))
{
  value = 10 - ((int)(1.0D / this.crit.getValue()) + 1);
  texts((int)(1.0D / this.crit.getValue()));
  texts((int)(1.0D / this.crit.getValue()), this.lblUntenlinks);
}
if (this.crit.getValue() > 1.0D)
{
  value = (int)this.crit.getValue() + 7;
  this.lblUnten.setText((int)this.crit.getValue());
  texts((int)this.crit.getValue(), this.lblUntenrechts);
}
this.scale.setSelection(value);

}


Convert the int to a String. You can use String.valueOf(value):

int value = 10; // Your value
yourLabel.setText(String.valueOf(value));