Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Loïc Perine
ProjetS2-2021-20-JMM
Commits
aa8d9174
Commit
aa8d9174
authored
Jun 25, 2021
by
Léo DUBOIS--JULIENNE
Browse files
plus de boutons
parent
203bc9ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/info1/Vue/ChoixModePartie.java
View file @
aa8d9174
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,89 +23,151 @@ import info1.application.appli;
*/
public
class
ChoixModePartie
extends
JDialog
{
private
Dimension
screenSize
=
Toolkit
.
getDefaultToolkit
().
getScreenSize
();
private
int
screenWidth
=
(
int
)
screenSize
.
getWidth
();
private
int
screenHeight
=
(
int
)
screenSize
.
getHeight
();
public
static
final
int
WIDTH
=
750
;
public
static
final
int
HEIGHT
=
200
;
private
JButton
etreHost
;
private
JButton
etreGuest
;
private
JButton
retourChoix
;
private
JPanel
choix
=
new
JPanel
();
/**
* Créer la vue de la fenêtre
*
* @param titre le titre de la fenêtre
*/
public
ChoixModePartie
(
String
titre
)
{
this
.
setTitle
(
titre
);
this
.
setModal
(
true
);
this
.
setModalityType
(
ModalityType
.
APPLICATION_MODAL
);
JPanel
panelPrincipal
=
new
JPanel
(
new
BorderLayout
());
etreHost
=
new
JButton
(
"Créer une partie"
);
etreGuest
=
new
JButton
(
"Trouver une partie"
);
retourChoix
=
new
JButton
(
"retour"
);
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
);
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
);
}
private
Dimension
screenSize
=
Toolkit
.
getDefaultToolkit
().
getScreenSize
();
private
int
screenWidth
=
(
int
)
screenSize
.
getWidth
();
private
int
screenHeight
=
(
int
)
screenSize
.
getHeight
();
public
static
final
int
WIDTH
=
750
;
public
static
final
int
HEIGHT
=
200
;
private
JButton
etreHost
;
private
JButton
etreGuest
;
private
JButton
retourChoix
;
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
*
* @param titre le titre de la fenêtre
*/
public
ChoixModePartie
(
String
titre
)
{
this
.
setTitle
(
titre
);
this
.
setModal
(
true
);
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
.
add
(
new
JPanel
());
choix
.
add
(
etreHost
);
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
);
}
}
src/info1/Vue/Resultat.java
View file @
aa8d9174
...
...
@@ -45,12 +45,47 @@ public class Resultat extends JDialog {
JPanel
panelPrincipal
=
new
JPanel
(
new
BorderLayout
());
quitter
=
new
JButton
(
"Quitter"
);
rejouer
=
new
JButton
(
"Refaire une partie"
);
nouvelleFlotte
=
new
JButton
(
"Créer une nouvelle flotte"
);
//création des boutons
gagner
=
new
JLabel
(
"Vous avez gagné !"
);
perdu
=
new
JLabel
(
"Vous avez perdu !"
);
vide
=
new
JPanel
();
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"
);
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
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"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment