import Java awt. *;
Import the Java. The awt. Event. *;
The import javax.mail. Swing. *;
Public class JKLL {
Public static void createAndShowGUI () {
JFrame frame=new JFrame (" test ");
Frame. SetLayout (new FlowLayout ());
Frame. SetLocation (300, 200);//determine the window position
JTextField tf=new JTextField (40);//create a text box
Frame. The add (tf);
Frame. SetDefaultCloseOperation (JFrame. EXIT_ON_CLOSE);
Frame. The setSize (500300);
frame.setVisible(true);
Tf. AddKeyListener (new KeyAdapter () {
Public void keypressed KeyEvent (e) {
Char ch=um participant etKeyChar ();
System. The out. Println (ch);
}
});
}
Public static void main (String [] args) {
SwingUtilities. InvokeLater (JKLL: : createAndShowGUI);
}
}
The code above, line 15 keypressed has been an error "The method keypressed KeyEvent (e) from The new KeyAdapter () is not informs The locally", how should solve? Ask for help,
CodePudding user response:
KeyPressedPay attention to the case