Of course, you may wish to construct a text field using an integer, rather
than a string. Such a wish requires you to convert the integer into a
string first, using the valueOf
class method found in the
String
class. In the following, the value of the int
variable, value1
, is converted:
field1 = new JTextField(String.valueOf(value1), 20);