From a2a83698e40176d31ae8afe5a68381221e1735d5 Mon Sep 17 00:00:00 2001 From: Berkan Sarp Date: Tue, 31 Jan 2023 23:45:28 +0100 Subject: [PATCH] Update add KeyAdapter --- src/main/java/GameFrame.java | 2 ++ src/main/java/MenuPanel.java | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/main/java/GameFrame.java diff --git a/src/main/java/GameFrame.java b/src/main/java/GameFrame.java new file mode 100644 index 0000000..91d7414 --- /dev/null +++ b/src/main/java/GameFrame.java @@ -0,0 +1,2 @@ +public class GameFrame { +} diff --git a/src/main/java/MenuPanel.java b/src/main/java/MenuPanel.java index 3d0d021..999a029 100644 --- a/src/main/java/MenuPanel.java +++ b/src/main/java/MenuPanel.java @@ -1,5 +1,7 @@ import javax.swing.*; import java.awt.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; public class MenuPanel extends JPanel { MenuPanel() { @@ -22,4 +24,14 @@ public class MenuPanel extends JPanel { g.setFont(new Font("Consolas", Font.PLAIN, 10)); g.drawString("Created by Hells Gamers", 450, 450); - } \ No newline at end of file + } + public class AL extends KeyAdapter { + + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + GameFrame gameFrame = new GameFrame(); + } + + } + } +} \ No newline at end of file