Made Listeners works

This commit is contained in:
Arthur 2021-02-12 17:58:19 +01:00
parent 33db153302
commit 1c655b405f
3 changed files with 42 additions and 6 deletions

View File

@ -41,10 +41,10 @@ public class MainFrame extends JFrame {
JToolBar toolBar = new JToolBar();
newGen = new JButton("Nouvelle génération");
newGen.addActionListener(new NewGenListener());
newGen.addActionListener(new NewGenListener(this));
toolBar.add(newGen);
help = new JButton("Aide");
help.addActionListener(new HelpListener());
help.addActionListener(new HelpListener(this));
toolBar.add(help);
this.setTitle("L-system interface");
@ -106,8 +106,30 @@ public class MainFrame extends JFrame {
list.append("-> "+stringToAdd + "\n");
}
}
public void sendRule(){
//TODO : send the string contain into a JTextField into the JTextAre ruleList or axiomList
public String getAxiom(){
String str = "";
// TODO : return the axiom
return str;
}
public ArrayList<String> getRules(){
ArrayList<String> list= new ArrayList<>();
//TODO return the rules
return list;
}
public void incorrect() {
JFrame alert = new JFrame();
alert.setTitle("Erreur");
alert.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
alert.setSize(60,40);
alert.setLocationRelativeTo(null);
JLabel text = new JLabel("Vos règles ou votre axiome ne sont pas correctement écrites, veuillez recommencer");
alert.add(text);
alert.setVisible(true);
changeList(null,(byte) 0,null);
changeList(null,(byte)1,null);
}
}

View File

@ -1,11 +1,19 @@
package lsystem.screen.listener;
import lsystem.screen.MainFrame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class HelpListener implements ActionListener {
MainFrame frame;
public HelpListener(MainFrame frame) {
this.frame = frame;
}
@Override
public void actionPerformed(ActionEvent e) {
frame.newHelp();
}
}

View File

@ -2,10 +2,16 @@ package lsystem.screen.listener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import lsystem.screen.MainFrame;
public class NewGenListener implements ActionListener {
MainFrame frame;
public NewGenListener(MainFrame frame) {
this.frame = frame;
}
@Override
public void actionPerformed(ActionEvent e) {
frame.newTab();
}
}