Created
March 21, 2012 19:01
-
-
Save anonymous/2151342 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.event.*; | |
import java.awt.*; | |
import javax.swing.*; | |
import java.util.*; | |
class KeyTest{ | |
public static void main(String[] args){ | |
SwingUtilities.invokeLater(new Runnable(){ | |
public void run() { | |
new Panell(); | |
} | |
}); | |
} | |
} | |
class Panell extends JFrame{ | |
Panell() { | |
setFocusable(true); | |
setPreferredSize(new Dimension(100, 100)); | |
addKeyListener(new KeyListen()); | |
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
pack(); | |
setVisible(true); | |
} | |
} | |
class KeyListen implements KeyListener{ | |
public void keyTyped(KeyEvent e){ | |
System.out.println("keyTyped()"); | |
} | |
public void keyPressed(KeyEvent e){ | |
System.out.println("keyPressed()"); | |
} | |
public void keyReleased(KeyEvent e){ | |
System.out.println("keyReleased()"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment