diff --git a/src/lsystem/screen/Tab.java b/src/lsystem/screen/Tab.java index a7fb8c7..e98f723 100644 --- a/src/lsystem/screen/Tab.java +++ b/src/lsystem/screen/Tab.java @@ -28,12 +28,12 @@ public class Tab { JLabel rules = new JLabel("Règle "+ nbRules+" :"); JTextField axiomeField = new JTextField(); - axiomeField.addKeyListener(new Listener(frame,nbTabs,"Axiom")); + axiomeField.addKeyListener(new Listener(frame,nbTabs,"Axiome")); axiomeField.setPreferredSize(new Dimension(120,20)); frame.addToTextFieldList(axiomeField,nbTabs); JTextField rulesField = new JTextField(); - rulesField.addKeyListener(new Listener(frame,nbTabs+10,"Rules")); + rulesField.addKeyListener(new Listener(frame,nbTabs+10,"Règles")); rulesField.setPreferredSize(new Dimension(120,20)); frame.addToTextFieldList(rulesField,nbTabs+10); diff --git a/src/lsystem/screen/listener/Listener.java b/src/lsystem/screen/listener/Listener.java index 35cee60..73ec7b4 100644 --- a/src/lsystem/screen/listener/Listener.java +++ b/src/lsystem/screen/listener/Listener.java @@ -57,8 +57,14 @@ public class Listener implements ActionListener, KeyListener { } @Override public void keyTyped(KeyEvent ke) { - if(ke.getKeyCode() != KeyEvent.VK_ENTER && nbAxioms==0) + if(nbAxioms==0 && ke.getKeyChar() !='\b') frame.changeList(String.valueOf(ke.getKeyChar()), (JTextArea) frame.textAreaList.get(index),nbAxioms); + if(ke.getKeyChar() == '\b'){ + String str = frame.textAreaList.get(index).getText(); + str = str.substring(10,str.length()-1); + frame.textAreaList.get(index).setText(type+" : \n"+str); + + } } @Override @@ -67,7 +73,7 @@ public class Listener implements ActionListener, KeyListener { frame.textFieldList.get(index).setText(null); String str = ";"; frame.changeList(str, (JTextArea) frame.textAreaList.get(index),nbAxioms); - if(type == "Axiom") + if(type == "Axiome") nbAxioms ++; } }