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

plus de boutons

parent 203bc9ac
package info1.Vue; package info1.Vue;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.event.ActionListener; 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.JButton;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JPanel; import javax.swing.JPanel;
...@@ -19,89 +23,151 @@ import info1.application.appli; ...@@ -19,89 +23,151 @@ import info1.application.appli;
*/ */
public class ChoixModePartie extends JDialog { public class ChoixModePartie extends JDialog {
private Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
private Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
private int screenWidth = (int) screenSize.getWidth();
private int screenWidth = (int) screenSize.getWidth(); private int screenHeight = (int) screenSize.getHeight();
private int screenHeight = (int) screenSize.getHeight(); public static final int WIDTH = 750;
public static final int WIDTH = 750; public static final int HEIGHT = 200;
public static final int HEIGHT = 200;
private JButton etreHost;
private JButton etreHost; private JButton etreGuest;
private JButton etreGuest; private JButton retourChoix;
private JButton retourChoix;
private JPanel choix = new JPanel();
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);
* Créer la vue de la fenêtre private static final Dimension DIMENSION_CHOIX = new Dimension((WIDTH - 2 * VGAP) / 3, 100);
*
* @param titre le titre de la fenêtre /**
*/ * Créer la vue de la fenêtre
public ChoixModePartie(String titre) { *
this.setTitle(titre); * @param titre le titre de la fenêtre
*/
this.setModal(true); public ChoixModePartie(String titre) {
this.setModalityType(ModalityType.APPLICATION_MODAL); this.setTitle(titre);
JPanel panelPrincipal = new JPanel(new BorderLayout());
this.setModal(true);
etreHost = new JButton("Créer une partie"); this.setModalityType(ModalityType.APPLICATION_MODAL);
etreGuest = new JButton("Trouver une partie"); JPanel panelPrincipal = new JPanel(new BorderLayout());
retourChoix = new JButton("retour");
try {
etreHost = new JButton(new ImageIcon(
choix.setLayout(new GridLayout(5,5)); (ImageIO.read(new File("img/interface/bouton/choixMode/BoutonCreer1.png"))).getScaledInstance(
choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); (int) DIMENSION_HOST.getWidth(), (int) DIMENSION_HOST.getHeight(), Image.SCALE_SMOOTH)));
etreHost.setRolloverIcon(new ImageIcon(
choix.add(new JPanel()); (ImageIO.read(new File("img/interface/bouton/choixMode/BoutonCreer1Hover.png"))).getScaledInstance(
choix.add(etreHost); (int) DIMENSION_HOST.getWidth(), (int) DIMENSION_HOST.getHeight(), Image.SCALE_SMOOTH)));
choix.add(new JPanel()); etreHost.setPressedIcon(
choix.add(etreGuest); new ImageIcon((ImageIO.read(new File("img/interface/bouton/choixMode/BoutonCreer1Pressed.png")))
choix.add(new JPanel()); .getScaledInstance((int) DIMENSION_HOST.getWidth(), (int) DIMENSION_HOST.getHeight(),
Image.SCALE_SMOOTH)));
choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); etreHost.setPreferredSize(DIMENSION_HOST);
etreGuest = new JButton(new ImageIcon(
choix.add(new JPanel()); (ImageIO.read(new File("img/interface/bouton/choixMode/BoutonTrouver1.png"))).getScaledInstance(
choix.add(new JPanel()); (int) DIMENSION_GUEST.getWidth(), (int) DIMENSION_GUEST.getHeight(), Image.SCALE_SMOOTH)));
choix.add(retourChoix); etreGuest.setRolloverIcon(
choix.add(new JPanel()); new ImageIcon((ImageIO.read(new File("img/interface/bouton/choixMode/BoutonTrouver1Hover.png")))
choix.add(new JPanel()); .getScaledInstance((int) DIMENSION_GUEST.getWidth(), (int) DIMENSION_GUEST.getHeight(),
Image.SCALE_SMOOTH)));
choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); choix.add(new JPanel()); etreGuest.setPressedIcon(
new ImageIcon((ImageIO.read(new File("img/interface/bouton/choixMode/BoutonTrouver1Pressed.png")))
choix.setPreferredSize(new Dimension(750, 200)); .getScaledInstance((int) DIMENSION_GUEST.getWidth(), (int) DIMENSION_GUEST.getHeight(),
choix.setVisible(true); Image.SCALE_SMOOTH)));
etreGuest.setPreferredSize(DIMENSION_GUEST);
panelPrincipal.add(choix); retourChoix = new JButton(new ImageIcon(
appli.setBgColorComponents(panelPrincipal); (ImageIO.read(new File("img/interface/bouton/choixMode/BoutonRetour1.png"))).getScaledInstance(
this.setContentPane(panelPrincipal); (int) DIMENSION_CHOIX.getWidth(), (int) DIMENSION_CHOIX.getHeight(), Image.SCALE_SMOOTH)));
this.setPreferredSize(new Dimension(WIDTH, HEIGHT)); retourChoix.setRolloverIcon(new ImageIcon(
this.setLocation((screenWidth-WIDTH)/2, (screenHeight-HEIGHT)/2); (ImageIO.read(new File("img/interface/bouton/choixMode/BoutonRetour1Hover.png"))).getScaledInstance(
this.pack(); (int) DIMENSION_CHOIX.getWidth(), (int) DIMENSION_CHOIX.getHeight(), Image.SCALE_SMOOTH)));
this.setResizable(false); retourChoix.setPressedIcon(
this.setAlwaysOnTop(true); 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);
* Gère le bouton "Créer une partie"
* } catch (IOException e) {
* @param action l'action de cliquer sur le bouton etreHost = new JButton("Créer une partie");
*/ etreGuest = new JButton("Trouver une partie");
public void fixeListenerEtreHost(ActionListener action) { etreHost.addActionListener(action); } retourChoix = new JButton("retour");
System.out.println("erreur lors du chargement d'une image");
/** e.printStackTrace();
* Gère le bouton "Rejoindre une partie" }
*
* @param action l'action de cliquer sur le bouton choix.setLayout(new GridLayout(5, 5));
*/ choix.add(new JPanel());
public void fixeListenerEtreGuest(ActionListener action) { etreGuest.addActionListener(action); } choix.add(new JPanel());
choix.add(new JPanel());
/** choix.add(new JPanel());
* Gère le bouton "Retour" choix.add(new JPanel());
*
* @param action l'action de cliquer sur le bouton choix.add(new JPanel());
*/ choix.add(etreHost);
public void fixeListenerRetourCreerFlotte(ActionListener action) { retourChoix.addActionListener(action); } choix.add(new JPanel());
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(retourChoix);
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);
panelPrincipal.add(choix);
appli.setBgColorComponents(panelPrincipal);
this.setContentPane(panelPrincipal);
this.setPreferredSize(new Dimension(WIDTH, HEIGHT));
this.setLocation((screenWidth - WIDTH) / 2, (screenHeight - HEIGHT) / 2);
this.pack();
this.setResizable(false);
this.setAlwaysOnTop(true);
}
/**
* Gère le bouton "Créer une partie"
*
* @param action l'action de cliquer sur le bouton
*/
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);
}
/**
* Gère le bouton "Retour"
*
* @param action l'action de cliquer sur le bouton
*/
public void fixeListenerRetourCreerFlotte(ActionListener action) {
retourChoix.addActionListener(action);
}
} }
...@@ -45,12 +45,47 @@ public class Resultat extends JDialog { ...@@ -45,12 +45,47 @@ public class Resultat extends JDialog {
JPanel panelPrincipal = new JPanel(new BorderLayout()); JPanel panelPrincipal = new JPanel(new BorderLayout());
quitter = new JButton("Quitter"); try {
rejouer = new JButton("Refaire une partie"); rejouer = new JButton(new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonRejouer1.png")))
nouvelleFlotte = new JButton("Créer une nouvelle flotte"); //création des boutons .getScaledInstance(175, 70, Image.SCALE_SMOOTH)));
gagner = new JLabel("Vous avez gagné !"); rejouer.setRolloverIcon(
perdu = new JLabel("Vous avez perdu !"); new ImageIcon((ImageIO.read(new File("img/interface/bouton/resultat/BoutonRejouer1Hover.png")))
vide = new JPanel(); .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");
gagner = new JLabel("Vous avez gagné !");
perdu = new JLabel("Vous avez perdu !");
System.out.println("erreur lors du chargement d'une image");
e.printStackTrace();
}
JPanel centre = new JPanel(); JPanel centre = new JPanel();
JPanel sud = new JPanel(); JPanel sud = new JPanel();
...@@ -84,42 +119,7 @@ public class Resultat extends JDialog { ...@@ -84,42 +119,7 @@ public class Resultat extends JDialog {
this.setResizable(false); 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" * Gère le bouton "Quitter"
......
Supports Markdown
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