2

In a Codename One project, I have the following code that generates some input TextArea:

for (int i = 0; i < titles.length; i++) {
            SpanLabel introTextTitle = new SpanLabel(titles[i], "Label");
            SpanLabel introText = new SpanLabel(descriptions[i], "LabelSmallThin");
            TextArea textArea = new TextArea("WriteHere", 2, 80, TextArea.ANY);
            uib.bind(properties[i], textArea);
            add(getSeparatorLine(null));
            add(introTextTitle);
            add(introText);
            add(textArea);
        }

My problem is that the user input in each TextArea is limited to 124 chars (including spaces). My question are:

  • How to increase the max length of the input? Indeed I want no input limit. The Java "String" object included in the Property binded to the TextArea should have a very high capacity (2^31-1 chars, https://stackoverflow.com/a/1179996/2670744)

  • What is the meaning of row and columns in the constructor of TextArea? Because the width of the TextArea is decided by the layout manager and it changes in every device, I don't understand the meaning of specify the number of columns (that I suppose to be the number of chars for each row).

Francesco Galgani
  • 6,137
  • 3
  • 20
  • 23

1 Answers1

2

Use setMaxSize(length); to set the length of input.

Rows/Columns determine the preferred size of the component. The layout manager ultimately makes the decision but it does that based on the preferred size value.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • Why does setting maxSize() gives single line textArea? How can I set multiple line textArea with maxSize? – beck Jul 24 '19 at 11:02
  • It doesn't. It limits the number of characters not row/columns – Shai Almog Jul 25 '19 at 02:26
  • I've an old project with old gui builder. If I build with latest version build, it has an issue. I checked building with versioned build 4.0, it worked. https://youtu.be/wmVxwB7JdcA Code: TextArea descriptionTextArea = new TextArea(); descriptionTextArea.setRows(10); descriptionTextArea.setHint("Details"); descriptionTextArea.setUIID("eventDescription"); descriptionTextArea.setMaxSize(5000); – beck Jul 25 '19 at 06:10
  • I don't follow what isn't working? Did `setMaxSize` stop working? – Shai Almog Jul 26 '19 at 02:50
  • setMaxSize works but after using it, the text doesn't go to the next line when it passes the screen end. It continues in a single line. As soon as it reaches the screen end, it should continue in next line. After keyboard is off, then it shows all the text in multiple line. see the video: https://youtu.be/wmVxwB7JdcA But if you dont use setMaxSize, it only allows 124 chars. – beck Jul 26 '19 at 06:04
  • I suggest opening a question instead of commenting on someone elses question. That way you can provide basic details such as the test case, platforms where this occurs etc. – Shai Almog Jul 27 '19 at 04:19