Search code examples
javaswingintjtextarea

Display integer in JTextArea


I have created a JTextArea as follows:

 JTextArea area = new JTextArea(20,15);
 add(new JScrollPane(area), BorderLayout.CENTER);

I want to it to display the integer "0" when the code runs. I dont know how to add an int to the Area. I have tried the following code for that :

   int a= 0;
   area.add(a);

BUT THIS DOES NOT WORK.


Solution

  • area.setText(String.valueOf(a));