Adding some changes
This commit is contained in:
parent
96ab815450
commit
a168e308be
@ -21,10 +21,12 @@ public class MainFrame extends JFrame {
|
||||
private JButton newGen;
|
||||
private JButton help;
|
||||
private int nbRules;
|
||||
public HashMap<Integer,Component> componentList;
|
||||
public HashMap<Integer,JTextArea> textAreaList;
|
||||
public HashMap<Integer,JTextField> textFieldList;
|
||||
|
||||
public MainFrame(){
|
||||
componentList = new HashMap<>();
|
||||
textAreaList = new HashMap<>();
|
||||
textFieldList = new HashMap<>();
|
||||
nbRules = 1;
|
||||
nbTabs = 0;
|
||||
basePanel = new JPanel();
|
||||
@ -47,8 +49,11 @@ public class MainFrame extends JFrame {
|
||||
this.add(toolBar, BorderLayout.NORTH);
|
||||
this.setPreferredSize(new Dimension(640,600));
|
||||
}
|
||||
public void addToComponentList(Component c ,Integer i){
|
||||
componentList.put(i,c);
|
||||
public void addToTextAreaList(JTextArea c ,Integer i){
|
||||
textAreaList.put(i,c);
|
||||
}
|
||||
public void addToTextFieldList(JTextField c ,Integer i){
|
||||
textFieldList.put(i,c);
|
||||
}
|
||||
|
||||
public void newHelp() {
|
||||
@ -66,7 +71,7 @@ public class MainFrame extends JFrame {
|
||||
public void closeTab() {
|
||||
//TODO : Pour fermer un onglet, nécessite l'implémentation d'un button fermer grâce à la méthode newTab().
|
||||
}
|
||||
public void changeList(Character stringToAdd, byte messageType, JTextArea list) {
|
||||
public void changeList(String stringToAdd, byte messageType, JTextArea list) {
|
||||
if (stringToAdd == null) {
|
||||
switch(messageType) {
|
||||
case 0:
|
||||
@ -77,7 +82,7 @@ public class MainFrame extends JFrame {
|
||||
throw new IllegalArgumentException("Wrong argument given to method changeList");
|
||||
}
|
||||
}else{
|
||||
list.append(String.valueOf(stringToAdd));
|
||||
list.append(stringToAdd);
|
||||
}
|
||||
}
|
||||
public String getAxiom(){
|
||||
|
@ -1,5 +1,7 @@
|
||||
package lsystem.screen;
|
||||
|
||||
import lsystem.screen.listener.AxiomFieldListener;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.JTabbedPane;
|
||||
@ -12,22 +14,27 @@ public class Tab {
|
||||
JTextArea axiomList = new JTextArea();
|
||||
axiomList.setText("Axiome : \n");
|
||||
axiomList.setEditable(false);
|
||||
frame.addToTextAreaList(axiomList,nbTabs);
|
||||
|
||||
JTextArea rulesList = new JTextArea();
|
||||
rulesList.setText("Règles : \n");
|
||||
rulesList.setEditable(false);
|
||||
frame.addToTextAreaList(rulesList,nbTabs+10);
|
||||
|
||||
JButton closeButton = new JButton("x");
|
||||
|
||||
|
||||
JLabel axiome = new JLabel("Axiome");
|
||||
JLabel rules = new JLabel("Règle "+ nbRules);
|
||||
|
||||
JTextField axiomeField = new JTextField();
|
||||
frame.addToComponentList(axiomeField,nbTabs);
|
||||
axiomeField.addKeyListener(new AxiomFieldListener(frame,nbTabs));
|
||||
axiomeField.setPreferredSize(new Dimension(20,20));
|
||||
frame.addToTextFieldList(axiomeField,nbTabs);
|
||||
|
||||
JTextField rulesField = new JTextField();
|
||||
frame.addToComponentList(rulesField,nbTabs+10);
|
||||
rulesField.setPreferredSize(new Dimension(20,20));
|
||||
|
||||
tab.add(axiome);
|
||||
tab.add(axiomeField);
|
||||
tab.add(axiomList);
|
||||
|
@ -19,16 +19,20 @@ public class AxiomFieldListener implements KeyListener {
|
||||
}
|
||||
@Override
|
||||
public void keyTyped(KeyEvent ke) {
|
||||
frame.changeList(ke.getKeyChar(),(byte)0, (JTextArea) frame.componentList.get(index));
|
||||
if(ke.getKeyCode() != 10)
|
||||
frame.changeList(String.valueOf(ke.getKeyChar()),(byte)0, (JTextArea) frame.textAreaList.get(index));
|
||||
else{
|
||||
String str = ";\n";
|
||||
frame.changeList(str,(byte)0, (JTextArea) frame.textAreaList.get(index));
|
||||
frame.textFieldList.get(index).setText("");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent ke) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent ke) {
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user