Skip to content

Instantly share code, notes, and snippets.

Created March 21, 2012 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2151342 to your computer and use it in GitHub Desktop.
Save anonymous/2151342 to your computer and use it in GitHub Desktop.
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