We can now erase rules and axioms

This commit is contained in:
Arthur 2021-02-17 15:31:00 +01:00
parent a29f8f5ec3
commit 2139f3d7c3
2 changed files with 10 additions and 4 deletions

View File

@ -28,12 +28,12 @@ public class Tab {
JLabel rules = new JLabel("Règle "+ nbRules+" :"); JLabel rules = new JLabel("Règle "+ nbRules+" :");
JTextField axiomeField = new JTextField(); JTextField axiomeField = new JTextField();
axiomeField.addKeyListener(new Listener(frame,nbTabs,"Axiom")); axiomeField.addKeyListener(new Listener(frame,nbTabs,"Axiome"));
axiomeField.setPreferredSize(new Dimension(120,20)); axiomeField.setPreferredSize(new Dimension(120,20));
frame.addToTextFieldList(axiomeField,nbTabs); frame.addToTextFieldList(axiomeField,nbTabs);
JTextField rulesField = new JTextField(); 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)); rulesField.setPreferredSize(new Dimension(120,20));
frame.addToTextFieldList(rulesField,nbTabs+10); frame.addToTextFieldList(rulesField,nbTabs+10);

View File

@ -57,8 +57,14 @@ public class Listener implements ActionListener, KeyListener {
} }
@Override @Override
public void keyTyped(KeyEvent ke) { 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); 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 @Override
@ -67,7 +73,7 @@ public class Listener implements ActionListener, KeyListener {
frame.textFieldList.get(index).setText(null); frame.textFieldList.get(index).setText(null);
String str = ";"; String str = ";";
frame.changeList(str, (JTextArea) frame.textAreaList.get(index),nbAxioms); frame.changeList(str, (JTextArea) frame.textAreaList.get(index),nbAxioms);
if(type == "Axiom") if(type == "Axiome")
nbAxioms ++; nbAxioms ++;
} }
} }