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.JButtonabtnAideprivate javax.swing.JButtonabtnAttraperprivate javax.swing.JButtonabtnBackprivate javax.swing.JButtonabtnBasprivate javax.swing.JButtonabtnEstprivate javax.swing.JButtonabtnHautprivate javax.swing.JButtonabtnNordprivate javax.swing.JButtonabtnOuestprivate javax.swing.JButtonabtnQuitprivate javax.swing.JButtonabtnSudprivate javax.swing.JButton[]aButtonsprivate GameEngineaEngineprivate javax.swing.JTextFieldaEntryFieldprivate javax.swing.JLabelaImageprivate javax.swing.JTextAreaaLogprivate javax.swing.JFrameaMyFrameprivate javax.swing.JPanelvPanel1private javax.swing.JPanelvPanel2
-
Constructor Summary
Constructors Constructor Description UserInterface(GameEngine pGameEngine)Construct a UserInterface.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(java.awt.event.ActionEvent pE)Actionlistener interface for entry textfield.voidclearText()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 voidcreateGUI()Set up graphical user interface.voidenable(boolean pOnOff)Enable or disable input in the input field.voidprint(java.lang.String pText)Print out some text into the text area.voidprintBold(java.lang.String pText, java.awt.Color pColor)Print out some text into the text area.voidprintln(java.lang.String pText)Print out some text into the text area, followed by a line break.private voidprocessCommand()A command has been entered.voidshowImage(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:
actionPerformedin interfacejava.awt.event.ActionListener
-
processCommand
private void processCommand()
A command has been entered. Read the command and do whatever is necessary to process it.
-
-