Esempio n. 1
0
  public GameFrame(int height, int width) {
    super("--- Tempo Game ---");

    this.height = height;
    this.width = width;

    card = new CardLayout();

    mainPanel = new JPanel();

    mainPanel.setLayout(card);

    memory[0] = new Memory();

    menuPanel = new MenuPanel(memory[count]);
    secondPanel = new SecondPanel(memory[count]);
    gamePanel = new GamePanel(memory[count]);
    rankPanel = new RankPanel(memory, count);

    mainPanel.add(menuPanel, "one");
    mainPanel.add(secondPanel, "two");
    mainPanel.add(gamePanel, "three");
    mainPanel.add(rankPanel, "four");

    buttonPanel = new JPanel();

    ctl = new JButton("- Play -");
    ctl.addActionListener(this);

    exit = new JButton("- Exit -");
    exit.addActionListener(this);

    rank = new JButton("- Rank -");
    rank.addActionListener(this);

    back = new JButton("- Back -");
    back.addActionListener(this);

    buttonPanel.add(ctl);
    buttonPanel.add(rank);
    buttonPanel.add(exit);
    buttonPanel.setOpaque(false);
    buttonPanel.setBounds(width / 2 - 50, height / 2 - 50, 80, 100);

    gamePanel.setFocusable(true);
    gamePanel.addKeyListener(this);

    add(buttonPanel);
    add(mainPanel);

    System.out.println(count);
  }