Update Interface TextFields
This commit is contained in:
parent
06b35e1983
commit
9f0142dfb8
@ -107,34 +107,25 @@ public class Listener implements ActionListener, KeyListener, MouseWheelListener
|
||||
@Override
|
||||
public void keyTyped(KeyEvent ke) {
|
||||
|
||||
byte i = (byte) ((type.equals("Axiome")) ? 0 : 1);
|
||||
|
||||
if(nbAxioms==0 && ke.getKeyChar() != '\b')
|
||||
tab.changeList(String.valueOf(ke.getKeyChar()), tab.getTextArea(i),nbAxioms);
|
||||
if(ke.getKeyChar() == '\b'){
|
||||
String str = tab.getTextArea(i).getText();
|
||||
if(str.length()>10) {
|
||||
if (!(str.endsWith(";\n") || str.endsWith(";"))){
|
||||
str = str.substring(10, str.length() - 1);
|
||||
tab.getTextArea(i).setText(type + " : \n" + str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent ke) {
|
||||
|
||||
byte i = (byte) ((type.equals("Axiome")) ? 0 : 1);
|
||||
|
||||
if(ke.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
byte i = (byte) ((type.equals("Axiome")) ? 0 : 1);
|
||||
String text = tab.getTextField(i).getText();
|
||||
text = ((text.charAt(text.length()-1)==';') ? "\n"+text : "\n"+text+";");
|
||||
tab.getTextField(i).setText(null);
|
||||
String str = ";";
|
||||
tab.changeList(str, tab.getTextArea(i),nbAxioms);
|
||||
if(i == 0)
|
||||
if(nbAxioms > 0 && i == 0)
|
||||
JOptionPane.showMessageDialog(null, "Nombre maximal d'axiomes créés");
|
||||
else {
|
||||
tab.getTextArea(i).append(text);
|
||||
nbAxioms ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent ke) {
|
||||
|
@ -23,8 +23,8 @@ public class Tab extends JPanel{
|
||||
this.nbRules = nbRules;
|
||||
this.nbTabs = nbTabs;
|
||||
|
||||
axiomList = textArea("Axiome : \n");
|
||||
rulesList = textArea("Règles : \n");
|
||||
axiomList = textArea("Axiome :");
|
||||
rulesList = textArea("Règles :");
|
||||
|
||||
JLabel itLabel = new JLabel("Nombre d'itérations : ");
|
||||
itSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 30, 1));
|
||||
@ -132,20 +132,7 @@ public class Tab extends JPanel{
|
||||
return (i == 0) ? axiomeField : rulesField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the maximal axioms number has been reach, if not, add the given String into the axiomList or into the rulesList.
|
||||
* @param stringToAdd the String to add into the JTextArea.
|
||||
* @param list the JTextArea where to add the String (axiomList or rulesList).
|
||||
* @param nb the number of Axioms that are already created (maximum 1).
|
||||
*/
|
||||
public void changeList(String stringToAdd, JTextArea list, int nb) {
|
||||
if(nb > 0)
|
||||
JOptionPane.showMessageDialog(null, "Nombre maximal d'axiomes créés");
|
||||
else {
|
||||
list.append(stringToAdd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A string which contains the axiom entered by the user.
|
||||
|
Loading…
Reference in New Issue
Block a user