I've been lately working on building a game, working on Key Listeners for now and the part "JTextField KeyCodeT = new JTextField("KeyCode:")" is where im getting and error at, ERROR: "Cannot find symbol", thanks in advance
import java.awt.event.*;
public class Key1 extends Applet implements KeyListener {
// A Text field that will display the key code
JTextField KeyCodeT = new JTextField("KeyCode:");
public Key1(){
KeyCodeT.addKeyListener(this); // listends for key inputs in the text field
KeyCodeT.setEditable(false); // disallow user input into the text field
add(KeyCodeT); // add the text field to the screen
setSize(300,300); // set the screen size
setVisible(true); // show the window on screen
}
// called when the key is pressed down
public void keyPressed(KeyEvent e) {
System.out.println("Key Pressed!!!");
}
// called when the key is released
public void keyReleased(KeyEvent e) {
System.out.println("Key Released!!!");
KeyCodeT.setText("Key Code:" + e.getKeyCode()); // displays the key code in the text box
}
// called when a key is typed
public void keyTyped(KeyEvent e) {
}
public static void main(String[] args) {
Key1 key = new Key1();
}
public void init() {
}
public void paint(Graphics g) {
setBackground(Color.black);
g.drawLine(8, 8, 492, 8);
g.drawLine(8, 292, 492, 292);
g.drawLine(8, 8, 8, 292);
g.drawLine(492, 8, 492 , 292);
g.setColor(Color.green);
g.fillRect(8, 8, 485, 285);
}
}