You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. import PingPong.GamePanel;
  2. import javax.swing.*;
  3. import java.awt.*;
  4. import java.awt.event.KeyAdapter;
  5. import java.awt.event.KeyEvent;
  6. import java.awt.event.KeyListener;
  7. public class MenuPanel extends JPanel {
  8. MenuPanel() {
  9. this.addKeyListener(new MenuPanel.AL());
  10. this.setBackground(Color.BLACK);
  11. this.setFocusable(true);
  12. this.setPreferredSize(GamePanel.SCREEN);
  13. }
  14. protected void paintComponent(Graphics g) {
  15. super.paintComponent(g);
  16. draw(g);
  17. }
  18. public void draw(Graphics g) {
  19. g.setColor(Color.WHITE);
  20. g.setFont(new Font("Consolas", Font.BOLD, 70));
  21. g.drawString("GAME MENU", 330, 100);
  22. g.setFont(new Font("Consolas", Font.BOLD, 30));
  23. g.drawString("Press 'ENTER' to start the game", 265, 200);
  24. g.setFont(new Font("Consolas", Font.PLAIN, 10));
  25. g.drawString("Created by Hells Gamers", 450, 450);
  26. }
  27. public class AL extends KeyAdapter {
  28. public void keyPressed(KeyEvent e) {
  29. if (e.getKeyCode() == KeyEvent.VK_1) {
  30. new GameFrame();
  31. }
  32. }
  33. }
  34. private class GameFrame {
  35. }
  36. }