I am looking for a simple solution to making first and last line of TextArea uneditable.
As seen on the picture, I need to keep the first and last line, user can edit or input whatever he wants in the curly brackets. I have actually come up with this simple class, but it kinda breaks when user manages to get the closing curly bracket on the second line, leaving no lines between the first and the last one, rendering the user unable to edit anything.
Thanks for all responses.
public static class ScriptArea extends TextArea {
@Override
public void replaceText(int start, int end, String text) {
String currentToStart = getText().substring(0, start);
String startToEnd = getText().substring(start);
if (currentToStart.contains("\n") && startToEnd.contains("\n")) {
super.replaceText(start, end, text.equals("\n")?"\n\t":text);
}
}
}