Update Interface TextFields
This commit is contained in:
parent
06b35e1983
commit
9f0142dfb8
@ -107,32 +107,23 @@ public class Listener implements ActionListener, KeyListener, MouseWheelListener
|
|||||||
@Override
|
@Override
|
||||||
public void keyTyped(KeyEvent ke) {
|
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
|
@Override
|
||||||
public void keyPressed(KeyEvent ke) {
|
public void keyPressed(KeyEvent ke) {
|
||||||
|
|
||||||
byte i = (byte) ((type.equals("Axiome")) ? 0 : 1);
|
|
||||||
|
|
||||||
if(ke.getKeyCode() == KeyEvent.VK_ENTER) {
|
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);
|
tab.getTextField(i).setText(null);
|
||||||
String str = ";";
|
if(nbAxioms > 0 && i == 0)
|
||||||
tab.changeList(str, tab.getTextArea(i),nbAxioms);
|
JOptionPane.showMessageDialog(null, "Nombre maximal d'axiomes créés");
|
||||||
if(i == 0)
|
else {
|
||||||
|
tab.getTextArea(i).append(text);
|
||||||
nbAxioms ++;
|
nbAxioms ++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ public class Tab extends JPanel{
|
|||||||
this.nbRules = nbRules;
|
this.nbRules = nbRules;
|
||||||
this.nbTabs = nbTabs;
|
this.nbTabs = nbTabs;
|
||||||
|
|
||||||
axiomList = textArea("Axiome : \n");
|
axiomList = textArea("Axiome :");
|
||||||
rulesList = textArea("Règles : \n");
|
rulesList = textArea("Règles :");
|
||||||
|
|
||||||
JLabel itLabel = new JLabel("Nombre d'itérations : ");
|
JLabel itLabel = new JLabel("Nombre d'itérations : ");
|
||||||
itSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 30, 1));
|
itSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 30, 1));
|
||||||
@ -132,20 +132,7 @@ public class Tab extends JPanel{
|
|||||||
return (i == 0) ? axiomeField : rulesField;
|
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.
|
* @return A string which contains the axiom entered by the user.
|
||||||
|
Loading…
Reference in New Issue
Block a user