We are trying to count the number of rows in a TextArea
Here are the TextArea properties PrefWidth 600 and PrefHeight 620 with MaxHeight 620
Wrap Text is set to true. We
Grendel this code seems to complicate the task of counting the \n by using the String[ ] array. This code posted below
// This counts ENTER key presses
String toCount = txaDiaryEntry.getText();
String [] lineArray = toCount.split("\n");
LA = lineArray.length - 1;
if(LA == tLA){
tLA = LA + 1;
RC = RC - 1;
}else if(tLA < LA){
tLA = LA + 1;
RC = RC - 1;
}else{
So rather than deal with the String [ ] array here is a little less code that just counts the occurrences of \n and as your original code did it subtracts a given number of characters
String toCount = txaDiaryEntry.getText();
S = toCount.split("\n",-1).length - 1;
RowCount = RowCount - 1;
// This test counter
int minus = EC+(S * 40);
int val = 1200 - minus ;
All the code to deal with the String [ ] array was clever but way crazy and hard to follow. Now you can play with the number 40 for perhaps a more realistic character count?