package semestralkaGUI;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import semestralka.AutomatConstructor;
import semestralka.Expression;
/**
*
* @author frantisek
*/
public class RunButtonListener implements ActionListener{
MainFrame caller;
public RunButtonListener(MainFrame caller) {
this.caller = caller;
}
@Override
public void actionPerformed(ActionEvent e) {
AutomatConstructor a = new AutomatConstructor();
Expression ex = new Expression(caller.input.getText(),true);
if(ex.isValid()){
caller.app.setAutomat(a.Construct(ex));
caller.log.add(a.getLog());
caller.log.repaint();
caller.setCanvasImage(caller.app.generateGraphFile());
}
else
JOptionPane.showMessageDialog(caller, "Invalid expression!");
}
}