Package ui

Class ScoreLabel

All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, SwingConstants

public class ScoreLabel extends JLabel implements PropertyChangeListener
A label that displays the current score and number of lives remaining in a game of PacMann.
See Also:
  • Field Details

    • model

      private GameModel model
      The model whose score and lives remaining we should display. May be null, in which case no score or lives values are displayed.
  • Constructor Details

    • ScoreLabel

      public ScoreLabel(GameModel model)
      Create a new label that will display the state of `model` (may be null).
  • Method Details

    • setModel

      public void setModel(GameModel newModel)
      Start displaying the state of `newModel`, instead of any model we may have been displaying before. Model must publish PropertyChangeEvents for "score" and "lives" properties. `newModel` may be null, in which case no score or lives values are displayed.
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Specified by:
      propertyChange in interface PropertyChangeListener
    • showModelState

      private void showModelState()
      Update our text to display the score and lives remaining in our current model.