Hi all,

I have the following code :

import javax.swing.*;
import java.awt.event.*;

public class TestFrame implements KeyListener

public TestFrame()
JOptionPane Obj = new JOptionPane();
Obj.showMessageDialog(null,"Hello World","Test",


public static void main(String[] args)
TestFrame testFrame = new TestFrame();

public final void keyPressed(KeyEvent e)
System.out.print("Hello World 2");

public final void keyTyped(KeyEvent e) {}
public final void keyReleased(KeyEvent e) {}

As you can see I'm trying to listen to the JOptionPane's keyevent, but when
I press any key it doesn't seem to respond as expected.

What's wrong with the code ?

Thanks in advance