Commit aa8d9174 authored by Léo DUBOIS--JULIENNE's avatar Léo DUBOIS--JULIENNE
Browse files

plus de boutons

parent 203bc9ac
package info1.Vue;
import java.awt.BorderLayout;
import java.awt.*;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
......@@ -19,7 +23,6 @@ import info1.application.appli;
*/
public class ChoixModePartie extends JDialog {
private Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
private int screenWidth = (int) screenSize.getWidth();
......@@ -33,6 +36,10 @@ public class ChoixModePartie extends JDialog {
private JPanel choix = new JPanel();
private static final int VGAP = 50;
private static final Dimension DIMENSION_HOST = new Dimension((WIDTH - 2 * VGAP) / 3, 100);
private static final Dimension DIMENSION_GUEST = new Dimension((WIDTH - 2 * VGAP) / 3, 100);
private static final Dimension DIMENSION_CHOIX = new Dimension((WIDTH - 2 * VGAP) / 3, 100);
/**
* Créer la vue de la fenêtre
......@@ -46,13 +53,56 @@ public class ChoixModePartie extends JDialog {
this.setModalityType(ModalityType.APPLICATION_MODAL);
JPanel panelPrincipal = new JPanel(new BorderLayout());
try {
etreHost = new JButton(new ImageIcon(
(ImageIO.read(new File("img/interface/bouton/choixMode/BoutonCreer1.png"))).getScaledInstance(
(int) DIMENSION_HOST.getWidth(), (int) DIMENSION_HOST.getHeight(), Image.SCALE_SMOOTH)));
etreHost.setRolloverIcon(new ImageIcon(
(ImageIO.read(new File("img/interface/bouton/choixMode/BoutonCreer1Hover.png"))).getScaledInstance(
(int) DIMENSION_HOST.getWidth(), (int) DIMENSION_HOST.getHeight(), Image.SCALE_SMOOTH)));
etreHost.setPressedIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/choixMode/BoutonCreer1Pressed.png")))
.getScaledInstance((int) DIMENSION_HOST.getWidth(), (int) DIMENSION_HOST.getHeight(),
Image.SCALE_SMOOTH)));
etreHost.setPreferredSize(DIMENSION_HOST);
etreGuest = new JButton(new ImageIcon(
(ImageIO.read(new File("img/interface/bouton/choixMode/BoutonTrouver1.png"))).getScaledInstance(
(int) DIMENSION_GUEST.getWidth(), (int) DIMENSION_GUEST.getHeight(), Image.SCALE_SMOOTH)));
etreGuest.setRolloverIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/choixMode/BoutonTrouver1Hover.png")))
.getScaledInstance((int) DIMENSION_GUEST.getWidth(), (int) DIMENSION_GUEST.getHeight(),
Image.SCALE_SMOOTH)));
etreGuest.setPressedIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/choixMode/BoutonTrouver1Pressed.png")))
.getScaledInstance((int) DIMENSION_GUEST.getWidth(), (int) DIMENSION_GUEST.getHeight(),
Image.SCALE_SMOOTH)));
etreGuest.setPreferredSize(DIMENSION_GUEST);
retourChoix = new JButton(new ImageIcon(
(ImageIO.read(new File("img/interface/bouton/choixMode/BoutonRetour1.png"))).getScaledInstance(
(int) DIMENSION_CHOIX.getWidth(), (int) DIMENSION_CHOIX.getHeight(), Image.SCALE_SMOOTH)));
retourChoix.setRolloverIcon(new ImageIcon(
(ImageIO.read(new File("img/interface/bouton/choixMode/BoutonRetour1Hover.png"))).getScaledInstance(
(int) DIMENSION_CHOIX.getWidth(), (int) DIMENSION_CHOIX.getHeight(), Image.SCALE_SMOOTH)));
retourChoix.setPressedIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/choixMode/BoutonRetour1Pressed.png")))
.getScaledInstance((int) DIMENSION_CHOIX.getWidth(), (int) DIMENSION_CHOIX.getHeight(),
Image.SCALE_SMOOTH)));
retourChoix.setPreferredSize(DIMENSION_CHOIX);
} catch (IOException e) {
etreHost = new JButton("Créer une partie");
etreGuest = new JButton("Trouver une partie");
retourChoix = new JButton("retour");
System.out.println("erreur lors du chargement d'une image");
e.printStackTrace();
}
choix.setLayout(new GridLayout(5,5));
choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel());
choix.setLayout(new GridLayout(5, 5));
choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel());
choix.add(etreHost);
......@@ -60,7 +110,11 @@ public class ChoixModePartie extends JDialog {
choix.add(etreGuest);
choix.add(new JPanel());
choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel());
......@@ -68,7 +122,11 @@ public class ChoixModePartie extends JDialog {
choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel());
choix.add(new JPanel());
choix.setPreferredSize(new Dimension(750, 200));
choix.setVisible(true);
......@@ -77,10 +135,12 @@ public class ChoixModePartie extends JDialog {
appli.setBgColorComponents(panelPrincipal);
this.setContentPane(panelPrincipal);
this.setPreferredSize(new Dimension(WIDTH, HEIGHT));
this.setLocation((screenWidth-WIDTH)/2, (screenHeight-HEIGHT)/2);
this.setLocation((screenWidth - WIDTH) / 2, (screenHeight - HEIGHT) / 2);
this.pack();
this.setResizable(false);
this.setAlwaysOnTop(true);
}
/**
......@@ -88,20 +148,26 @@ public class ChoixModePartie extends JDialog {
*
* @param action l'action de cliquer sur le bouton
*/
public void fixeListenerEtreHost(ActionListener action) { etreHost.addActionListener(action); }
public void fixeListenerEtreHost(ActionListener action) {
etreHost.addActionListener(action);
}
/**
* Gère le bouton "Rejoindre une partie"
*
* @param action l'action de cliquer sur le bouton
*/
public void fixeListenerEtreGuest(ActionListener action) { etreGuest.addActionListener(action); }
public void fixeListenerEtreGuest(ActionListener action) {
etreGuest.addActionListener(action);
}
/**
* Gère le bouton "Retour"
*
* @param action l'action de cliquer sur le bouton
*/
public void fixeListenerRetourCreerFlotte(ActionListener action) { retourChoix.addActionListener(action); }
public void fixeListenerRetourCreerFlotte(ActionListener action) {
retourChoix.addActionListener(action);
}
}
......@@ -45,12 +45,47 @@ public class Resultat extends JDialog {
JPanel panelPrincipal = new JPanel(new BorderLayout());
try {
rejouer = new JButton(new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonRejouer1.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
rejouer.setRolloverIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonRejouer1Hover.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
rejouer.setPressedIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonRejouer1Pressed.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
rejouer.setPreferredSize(DIMENSION_REJOUER);
nouvelleFlotte = new JButton(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonRetourFlotte1.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
nouvelleFlotte.setRolloverIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonRetourFlotte1Hover.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
nouvelleFlotte.setPressedIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonRetourFlotte1Pressed.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
nouvelleFlotte.setPreferredSize(DIMENSION_NOUVELLEFLOTTE);
quitter = new JButton(new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonQuitter1.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
quitter.setRolloverIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonQuitter1Hover.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
quitter.setPressedIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonQuitter1Pressed.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
quitter.setPreferredSize(DIMENSION_QUITTER);
}catch(
IOException e)
{
quitter = new JButton("Quitter");
rejouer = new JButton("Refaire une partie");
nouvelleFlotte = new JButton("Créer une nouvelle flotte"); //création des boutons
nouvelleFlotte = new JButton("Créer une nouvelle flotte");
gagner = new JLabel("Vous avez gagné !");
perdu = new JLabel("Vous avez perdu !");
vide = new JPanel();
System.out.println("erreur lors du chargement d'une image");
e.printStackTrace();
}
JPanel centre = new JPanel();
JPanel sud = new JPanel();
......@@ -84,42 +119,7 @@ public class Resultat extends JDialog {
this.setResizable(false);
}
try {
rejouer = new JButton(new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonRejouer1.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
rejouer.setRolloverIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonRejouer1Hover.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
rejouer.setPressedIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonRejouer1Pressed.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
rejouer.setPreferredSize(DIMENSION_REJOUER);
nouvelleFlotte = new JButton(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonRetourFlotte1.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
nouvelleFlotte.setRolloverIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonRetourFlotte1Hover.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
nouvelleFlotte.setPressedIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonRetourFlotte1Pressed.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
nouvelleFlotte.setPreferredSize(DIMENSION_NOUVELLEFLOTTE);
quitter = new JButton(new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonQuitter1.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
quitter.setRolloverIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonQuitter1Hover.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
quitter.setPressedIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonQuitter1Pressed.png")))
.getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
quitter.setPreferredSize(DIMENSION_QUITTER);
}catch(
IOException e)
{
System.out.println("erreur lors du chargement d'une image");
e.printStackTrace();
}
/**
* Gère le bouton "Quitter"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment