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