package fr.iutfbleau.but2.projet;
import java.net.URL;
import java.awt.CardLayout;
import java.awt.BorderLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.*;

public class fenetre extends JFrame implements MouseListener{

    int imgN = 0;
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    URL[] imgs = {loader.getResource("res/0495Snivy.png"),loader.getResource("res/0498Tepig.png"),loader.getResource("res/0501Oshawott.png")};

    public fenetre()
    {
        super();
        this.setSize(1000, 1000);
	    this.setLocation(0, 0);
        this.add(new JLabel(new ImageIcon(this.imgs[this.imgN])),BorderLayout.CENTER);
        addMouseListener(this);

    }

    public void next()
    {

    }

    public void previous()
    {

    }

    public void nextOld()
    {
        if (this.imgN+1>=imgs.length) 
        {
            this.imgN = 0;
        } 
        else 
        {
            this.imgN++;
        }
        this.getContentPane().removeAll();
        this.add(new JLabel(new ImageIcon(this.imgs[this.imgN])),BorderLayout.CENTER);
        this.repaint();
        this.revalidate();
    }

    public void previousOld()
    {
        if (this.imgN-1<0) 
        {
            this.imgN = imgs.length-1;
        } 
        else 
        {
            this.imgN--;
        }
        this.getContentPane().removeAll();
        this.add(new JLabel(new ImageIcon(this.imgs[this.imgN])),BorderLayout.CENTER);
        this.repaint();
        this.revalidate();
    }

    @Override
    public void mouseClicked(MouseEvent e)
    {
        if (e.getX()<this.getWidth()/2) 
        {
            this.previousOld();
        } 
        else 
        {
            this.nextOld();
        }
    }

    @Override
    public void mouseEntered(MouseEvent e) {}

    @Override
    public void mouseExited(MouseEvent e) {}

    @Override
    public void mousePressed(MouseEvent e) {}

    @Override
    public void mouseReleased(MouseEvent e) {}
}