Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.97 KB | None | 0 0
  1. package AuiAs2;
  2.  
  3. import AuiAs2.Controller.DiffControl;
  4. import AuiAs2.Model.Model;
  5. import AuiAs2.View.DiffView;
  6. import AuiAs2.View.EndGameView;
  7. import AuiAs2.View.GameView;
  8.  
  9. import javax.swing.*;
  10. import java.awt.*;
  11.  
  12. /**
  13.  * Main class for Maths Game application.
  14.  *
  15.  *
  16.  */
  17. public class MathsGame extends JFrame {
  18.     private JPanel panContainer = new JPanel();
  19.  
  20.     private CardLayout layCard = new CardLayout();
  21.    
  22.     private static final int WIDTH = 800; //default application weight
  23.     private static final int HEIGHT = 600; //default application height
  24.     private static final int MIN_WIDTH = 600; //minimum width for the application window
  25.     private static final int MIN_HEIGHT = 450; //minimum height for the application window
  26.     private static final String TITLE = "Maths Game";
  27.  
  28.     public MathsGame() {
  29.         panContainer.setLayout(layCard);
  30.         setContentPane(panContainer);
  31.         setSize(new Dimension(WIDTH, HEIGHT));
  32.         setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
  33.         setTitle(TITLE);
  34.  
  35.         JMenuBar menbMenu = new JMenuBar();
  36.  
  37.         JMenu jmFile = new JMenu("File");
  38.         JMenuItem jmiNewGame = new JMenuItem("New Game");
  39.         JMenuItem jmiChangeDif = new JMenuItem("Change Difficulty");
  40.         JMenuItem jmiSaveScores = new JMenuItem("Save Scores");
  41.         JMenuItem jmiLoadScores = new JMenuItem("Load Scores");
  42.         jmFile.add(jmiNewGame);
  43.         jmFile.add(jmiChangeDif);
  44.         jmFile.add(jmiSaveScores);
  45.         jmFile.add(jmiLoadScores);
  46.         menbMenu.add(jmFile);
  47.  
  48.         JMenu jmHelp = new JMenu("Help");
  49.         JMenuItem jmiRules = new JMenuItem("Rules");
  50.         JMenuItem jmiInfo = new JMenuItem("Information");
  51.         jmHelp.add(jmiRules);
  52.         jmHelp.add(jmiInfo);
  53.         menbMenu.add(jmHelp);
  54.  
  55.         setJMenuBar(menbMenu);
  56.  
  57.         DiffView panDiffView = new DiffView();
  58.         panContainer.add(panDiffView, "Choose Difficulty");
  59.  
  60.         GameView panGameView = new GameView();
  61.         panContainer.add(panGameView, "New Game");
  62.  
  63.         EndGameView panEndGameView = new EndGameView();
  64.         panContainer.add(panEndGameView, "End Game");
  65.  
  66.         Model model = new Model();
  67.  
  68.         DiffControl diffControl = new DiffControl(panDiffView, model);
  69.         //GameControl gameControl = new GameControl(panGameView, model);
  70.         //EndGameControl EndGameControl = new EndGameControl(panEndGameView, model);
  71.  
  72.         layCard.show(panContainer, "Choose Difficulty");
  73.  
  74.         setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  75.         setVisible(true);
  76.     }
  77.  
  78.  
  79.     public void switchToDiff() {
  80.         layCard.show(panContainer, "New Game");
  81.     }
  82.  
  83.     public void switchToGame() {
  84.         layCard.show(panContainer, "New Game");
  85.     }
  86.  
  87.     public void switchToEnd() {
  88.         layCard.show(panContainer, "New Game");
  89.     }
  90.  
  91.     public static void main(String[] args) {
  92.         SwingUtilities.invokeLater(MathsGame::new);
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement