package vue;
import java.awt.EventQueue;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class ChoixJoueur extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel contentPane;

	/**
	 * Launch the application.
	 */

	/**
	 * Create the frame.
	 */
	public ChoixJoueur() {
		setTitle("Choice");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.getContentPane().setPreferredSize(new Dimension(400, 275));
		this.pack();
		this.setResizable(false);
		setBounds(100, 100, 412, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("");
		String chemin = "fonds/fondchoix.jpg";
		URL ressourceURL = getClass().getClassLoader().getResource(chemin);

		if (ressourceURL != null) {
		    String ressource = URLDecoder.decode(ressourceURL.getPath(), StandardCharsets.UTF_8);
		    lblNewLabel.setIcon(new ImageIcon(ressource));
		} else {
		    System.out.println("❌ Image non trouvée !");
		}
		
		lblNewLabel.setBounds(0, 0, 396, 261);
		contentPane.add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("");
		lblNewLabel_1.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				System.out.println("Suivant");
			}
		});
		lblNewLabel_1.setBackground(new Color(128, 255, 0));
		lblNewLabel_1.setBounds(293, 108, 93, 81);
		contentPane.add(lblNewLabel_1);
		
		JLabel lblNewLabel_1_1 = new JLabel("");
		lblNewLabel_1_1.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				System.out.println("Précédent");
			}
		});
		lblNewLabel_1_1.setBackground(new Color(128, 255, 0));
		lblNewLabel_1_1.setBounds(10, 96, 93, 81);
		contentPane.add(lblNewLabel_1_1);
		
		JLabel lblNewLabel_2 = new JLabel("");
		lblNewLabel_2.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				Arene arena = new Arene();
				arena.setVisible(true);
				ChoixJoueur.this.dispose();
			}
		});
		lblNewLabel_2.setBounds(293, 200, 103, 61);
		contentPane.add(lblNewLabel_2);
	}

}
