# Question about GTextArea.setText() in G4P

**URL:** <https://discourse.processing.org/t/question-about-gtextarea-settext-in-g4p/20856>\
**Category:** Libraries\
**Created:** [May 14, 2020, 10:18am UTC](https://discourse.processing.org/t/question-about-gtextarea-settext-in-g4p/20856 "2020-05-14T10:18:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [May 14, 2020, 10:18am UTC](https://discourse.processing.org/t/question-about-gtextarea-settext-in-g4p/20856/1 "2020-05-14T10:18:00Z")

</div>

I have a question about GTextArea.setText(). I wrote a function that loads some lines from a text file and then uses GTextArea.setText() to load the lines into a text area. It seemed to be skipping empty lines, and at first I thought it was the loadStrings() function that was skipping them. But it appears that GTextArea.setText() is skipping the blank lines. Is it supposed to do that?

Here’s my code:

```auto
  public void loadHelp() {
    File file = null;
    int help = this.helpList.getSelectedIndex();
    file = new File(dataPath(fileList[help]));
    if (file.isFile()) {
      String[] lines = loadStrings(file);
      for (int i=0; i<lines.length; i++) {
        println(i,lines[i]);
      }
      this.helpText.setText(lines);
      this.message.setText("");
    } else {
      this.helpText.setText(descList);
      this.message.setText("Help file not available.");
    }
  }

```

It displays the following messages in the console log:

```auto
0 Var Delay : variable length delay
1 
2 CV 1 : delay amount in ms. (2 - 5000)
3 
4 CV 2 : feedback amount (0 - 100%)

```

But as you can see in the screen print, the blank lines are missing.

Thanks again.  
 ![setText](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/356749a46fd82dacbba20c6a47c38c7ac940c746.png)

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [May 14, 2020, 10:27am UTC](https://discourse.processing.org/t/question-about-gtextarea-settext-in-g4p/20856/2 "2020-05-14T10:27:22Z")

</div>

P.S. I got around the problem by padding each line with an extra space before calling GTextArea.setText(). So it seems that it skips lines of zero length ("") but not lines with at least one character, even a space, such as " ".

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [May 14, 2020, 10:47am UTC](https://discourse.processing.org/t/question-about-gtextarea-settext-in-g4p/20856/3 "2020-05-14T10:47:31Z")

</div>

If you try the G4P\_TextAreaControl example you will see the this control supports multiple styles for part or all of the text. It does this using the G4P library class `StyledString` which gives you great control over the text appearance. This class is heavily dependent on some low level Java classes and the only limitation is when editing the text in GTextArea the text insertion point generates an exception if it is on an empty line (length == 0). The only workaround I could find was to strip away empty lines when using `setText(...)` or to use a single space.

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [May 14, 2020, 10:55am UTC](https://discourse.processing.org/t/question-about-gtextarea-settext-in-g4p/20856/4 "2020-05-14T10:55:57Z")

</div>

Thanks. Might be an idea to add a note to the documentation then.
