can someone please tell me what the difference between these 2 main classes are and why one supports a KeyListener and the other doesn't?
public class Main {
public static void main(String[] args) {
JFrame window = new JFrame("Offbrand Tetris");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setResizable(false);
window.setUndecorated(true);
GamePanel gp = new GamePanel();
gp.launchGame();
window.add(gp);
window.pack();
window.setLocationRelativeTo(null);
window.setVisible(true);
GamePanel.device.setFullScreenWindow(window);
}
}``` Main 1 (supports)
```java
public class Main {
public static void main(String[] args) {
JFrame window = new JFrame();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setResizable(false);
window.setTitle("Game");
window.setLocationRelativeTo(null);
window.setUndecorated(true);
window.setVisible(true);
GamePanel gp = new GamePanel();
window.add(gp);
window.pack();
GamePanel.device.setFullScreenWindow(window);
gp.startGameThread();
}
}``` Main 2 (doesn't support)
(GamePanel extends JPanel implements Runnable)