Package a6

Class GameMain

java.lang.Object
a6.GameMain

public class GameMain extends Object
Main class for Click-a-Dot game. Creates window with game board, score label, start button, and sliders for target size and speed.
  • Constructor Details

    • GameMain

      public GameMain()
  • Method Details

    • main

      public static void main(String[] args)
      Start the application.
    • createAndShowGUI

      private static void createAndShowGUI()
      Create application window.
      • Window title is "Click-a-Dot"
      • Game board is in center of window, expands to fill window size
      • Score label is at top; text is centered
      • Start button is at bottom
      • Size slider is at right
      • Speed slider is at left
      Window should be disposed when closed, and all game tasks stopped. This should be sufficient for application to shut down gracefully.
    • addSliderLabels

      private static void addSliderLabels(JSlider slider, String minLabel, String maxLabel)
      Label `slider`'s minimum value with `minLabel` and its maximum value with `maxLabel`.
    • makeSliderPanel

      private static JComponent makeSliderPanel(JSlider slider, String title)
      Place `slider` in a new padded panel with top label `title` and return the panel.
    • saveScore

      private static void saveScore(JFrame frame, int score)
      Append a line containing `score` to a user-selected file, using `frame` as the parent of any dialogs. Show an error dialog if a problem occurs when writing the file.