Class UserInterface
- java.lang.Object
-
- UserInterface
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.util.EventListener
public class UserInterface extends java.lang.Object implements java.awt.event.ActionListener
This class implements a simple graphical user interface with a text entry area, a text output area and an optional image.- Version:
- 1.0 (Jan 2003), DB edited (2019), AF edited (2021)
- Author:
- Michael Kolling - Alban FERRACANI
-
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.JButton
abtnAide
private javax.swing.JButton
abtnAttraper
private javax.swing.JButton
abtnBack
private javax.swing.JButton
abtnBas
private javax.swing.JButton
abtnEst
private javax.swing.JButton
abtnHaut
private javax.swing.JButton
abtnNord
private javax.swing.JButton
abtnOuest
private javax.swing.JButton
abtnQuit
private javax.swing.JButton
abtnSud
private javax.swing.JButton[]
aButtons
private GameEngine
aEngine
private javax.swing.JTextField
aEntryField
private javax.swing.JLabel
aImage
private javax.swing.JTextArea
aLog
private javax.swing.JFrame
aMyFrame
private javax.swing.JPanel
vPanel1
private javax.swing.JPanel
vPanel2
-
Constructor Summary
Constructors Constructor Description UserInterface(GameEngine pGameEngine)
Construct a UserInterface.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent pE)
Actionlistener interface for entry textfield.void
clearText()
Efface le texte de l'interface graphique Méthode appelée pour effacer l'historique des affichages à la fin du jeu pour afficher le message final.private void
createGUI()
Set up graphical user interface.void
enable(boolean pOnOff)
Enable or disable input in the input field.void
print(java.lang.String pText)
Print out some text into the text area.void
printBold(java.lang.String pText, java.awt.Color pColor)
Print out some text into the text area.void
println(java.lang.String pText)
Print out some text into the text area, followed by a line break.private void
processCommand()
A command has been entered.void
showImage(java.lang.String pImageName)
Affiche une image sur l'user interface.
-
-
-
Field Detail
-
aEngine
private GameEngine aEngine
-
aMyFrame
private javax.swing.JFrame aMyFrame
-
aEntryField
private javax.swing.JTextField aEntryField
-
aLog
private javax.swing.JTextArea aLog
-
aImage
private javax.swing.JLabel aImage
-
abtnAide
private javax.swing.JButton abtnAide
-
abtnQuit
private javax.swing.JButton abtnQuit
-
abtnAttraper
private javax.swing.JButton abtnAttraper
-
abtnNord
private javax.swing.JButton abtnNord
-
abtnSud
private javax.swing.JButton abtnSud
-
abtnOuest
private javax.swing.JButton abtnOuest
-
abtnEst
private javax.swing.JButton abtnEst
-
abtnHaut
private javax.swing.JButton abtnHaut
-
abtnBas
private javax.swing.JButton abtnBas
-
abtnBack
private javax.swing.JButton abtnBack
-
aButtons
private javax.swing.JButton[] aButtons
-
vPanel1
private javax.swing.JPanel vPanel1
-
vPanel2
private javax.swing.JPanel vPanel2
-
-
Constructor Detail
-
UserInterface
public UserInterface(GameEngine pGameEngine)
Construct a UserInterface. As a parameter, a Game Engine (an object processing and executing the game commands) is needed.
-
-
Method Detail
-
print
public void print(java.lang.String pText)
Print out some text into the text area.
-
printBold
public void printBold(java.lang.String pText, java.awt.Color pColor)
Print out some text into the text area. Permet d'afficher ce texte avec une police, couleur spécifique.- Parameters:
pText
- (String) pour le texte à afficher.pColor
- (Color) pour la couleur du texte à afficher.
-
println
public void println(java.lang.String pText)
Print out some text into the text area, followed by a line break.
-
showImage
public void showImage(java.lang.String pImageName)
Affiche une image sur l'user interface.
-
enable
public void enable(boolean pOnOff)
Enable or disable input in the input field. Permet également d'afficher l'image de fin dans le cas où le jeu a été gagné, perdu ou quitté.- Parameters:
pOnOff
- (booleen) pour rendre enable ou disable l'interface utilisateur.
-
clearText
public void clearText()
Efface le texte de l'interface graphique Méthode appelée pour effacer l'historique des affichages à la fin du jeu pour afficher le message final.
-
createGUI
private void createGUI()
Set up graphical user interface.
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent pE)
Actionlistener interface for entry textfield.- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
processCommand
private void processCommand()
A command has been entered. Read the command and do whatever is necessary to process it.
-
-