simple question about swing
Respected Members,
I am making a very simple program in Java swing using jdk1.4.2, the program simply contains a JFrame and nothing else,what it is simply doing that I have binded an event to this frame and which is that every time the user presses Ctrl-F3(control and F3 key) so a message is displayed stating for example that "you pressed right key", but my program is not working, the probelm is that the event dont get fired,if I test it indivisually for Ctrl or F3 than the event is fiered and every thing works fine, the code is:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
publicclass SwingEventTest
{
publicstaticvoid main(String [] args)
{
JFrame f =new JFrame("This is a test");
f.setSize(400, 300);
f.setTitle("Test Frame....");
f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
Container contentPane = f.getContentPane();
contentPane.setBackground(Color.white);
contentPane.setFocusable(true);
contentPane.setLayout(null);
contentPane.addKeyListener(new MyKeyListener());
f.setVisible(true);
}
}
class MyKeyListenerextends KeyAdapter
{
publicvoid keyPressed(KeyEvent evt)
{
int iCode = evt.getKeyCode();
if (iCode == KeyEvent.VK_CONTROL && iCode == KeyEvent.VK_F3)
{
JOptionPane.showMessageDialog(null,"You pressed Ctrl+F3 so this event has been fiered and trapped");
}
}
}
Please tell me the error in this code, I would be waiting for your reply so please reply as soon as possible.
Thanking You,
Taqi Raza.

