标签:log void swing stat vax extends java 事件监听 imp
package com.at221; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.JFrame; public class TestKey { public static void main(String[] args) { JFrame f = new JFrame(); f.addKeyListener(new MyKeyListener()); f.setVisible(true); f.setSize(300, 300); } } class MyKeyListener extends KeyAdapter{ public void keyTyped(KeyEvent e) {//当键盘敲击某个按键时产生的事件: System.out.println(e.getKeyChar()); } public void keyPressed(KeyEvent e) {//当键盘按下某个键产生的事件; // System.out.println("hello!"); } public void keyReleased(KeyEvent e) {//当键盘上的某个按键被释放时产生的时间; // System.out.println("byebye!!!"); } }
标签:log void swing stat vax extends java 事件监听 imp
原文地址:http://www.cnblogs.com/zhaoningzyn/p/6882021.html