Class 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
    • 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.
      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.
      void showImage​(java.lang.String pImageName)
      Affiche une image sur l'user interface.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent pE)
        Actionlistener interface for entry textfield.
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener