From 73ef819bb3584eae94699190aa5cfadb35e6938d Mon Sep 17 00:00:00 2001 From: Arthur <78031901+Arthur7770@users.noreply.github.com> Date: Wed, 17 Feb 2021 16:07:01 +0100 Subject: [PATCH] Backspace works --- src/lsystem/screen/listener/Listener.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lsystem/screen/listener/Listener.java b/src/lsystem/screen/listener/Listener.java index 47e14aa..fe10cc1 100644 --- a/src/lsystem/screen/listener/Listener.java +++ b/src/lsystem/screen/listener/Listener.java @@ -57,13 +57,12 @@ public class Listener implements ActionListener, KeyListener { frame.changeList(String.valueOf(ke.getKeyChar()), frame.textAreaList.get(index),nbAxioms); if(ke.getKeyChar() == '\b'){ String str = frame.textAreaList.get(index).getText(); - if(str.length()>11) { - str = str.substring(10, str.length() - 1); - frame.textAreaList.get(index).setText(type + " : \n" + str); + if(str.length()>10) { + if (!(str.endsWith(";\n") || str.endsWith(";"))){ + str = str.substring(10, str.length() - 1); + frame.textAreaList.get(index).setText(type + " : \n" + str); + } } - else - frame.textAreaList.get(index).setText(type+" : \n"); - } }