package projet_freyja.ihm;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class MainWindow extends JFrame{
    
    protected JButton boutonEV;
    protected JButton boutonAL;
    protected JButton boutonPoly;
    protected JButton boutonBase;
    
    //Constructeur de la fenêtre
    public MainWindow(){ 
        //Création et paramétrage de la fenêtre principale
        this.setTitle("Main Window");
        this.setSize(800, 600);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        //Création d'un layout pour contenir les boutons
        this.setLayout(new GridLayout(4, 1));
        
        //Création des boutons
        boutonEV = new JButton("Espaces Vectoriels");
        boutonAL = new JButton("Applications Linéaires");
        boutonPoly = new JButton("Polynômes");
        boutonBase = new JButton("Bases");
        
        //Ecoute des boutons
        boutonEV.addActionListener(new ButtonEVListener());
        boutonAL.addActionListener(new ButtonALListener());
        boutonPoly.addActionListener(new ButtonPolyListener());
        boutonBase.addActionListener(new ButtonBaseListener());
        
        //Placement des boutons
        this.getContentPane().add(boutonEV);
        this.getContentPane().add(boutonAL);
        this.getContentPane().add(boutonPoly);
        this.getContentPane().add(boutonBase);
        
        this.pack();
        
        this.setVisible(true);
    }
    
    class ButtonEVListener implements ActionListener{
        @Override
        public void actionPerformed(ActionEvent arg0){
            WindowEV fenEv = new WindowEV();
        }
    }
    
    class ButtonALListener implements ActionListener{
        @Override
        public void actionPerformed(ActionEvent arg0){
            WindowAL fenAl = new WindowAL();
        }
    }
    
    class ButtonPolyListener implements ActionListener{
        @Override
        public void actionPerformed(ActionEvent arg0){
            WindowPoly fenPoly = new WindowPoly();
        }
    }
    
    class ButtonBaseListener implements ActionListener{
        @Override
        public void actionPerformed(ActionEvent arg0){
            WindowBase fenBase = new WindowBase();
        }
    }
}
