Class SetupView

All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class SetupView extends JFrame implements ActionListener
This class contains the code to create and layout the GUI for the setup screen. It also is the observer of the submit button. When someone clicks on submit the action performed method is called, which then calls the controller Object.

You do not need to make any changes to this file, but it is a good example of a Java swing GUI.

See Also:
  • Constructor Details

    • SetupView

      public SetupView()

      This creates a screen for setting up a new game.

      Post:
      [ a functional screen with the options for a new game ]
  • Method Details

    • actionPerformed

      public void actionPerformed(ActionEvent event)

      This is the callback method that gets called as part of the observer pattern.

      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      event - The event on the screen that is observed
      Post:
      [ button events will be sent to the controller ]
    • displayError

      public void displayError(String msg)

      This method displays an error message on the screen.

      Parameters:
      msg - The message to display in our text area
      Post:
      [ the this.errorMessageLbl text = m ]
    • registerObserver

      public void registerObserver(SetupController c)

      This method registers argument as observer/listener of this; this must be done first, before any other methods of this class are called.

      Parameters:
      c - Controller to register
      Pre:
      [ c is a valid controller for this view ]
      Post:
      this.controller = c
    • closeScreen

      public void closeScreen()

      This method closes the screen by disposing it.

      Post:
      [ This screen is properly disposed ]