keyListener in JWindow

M

Martin Gregorie

Mahdi said:
I can't control key events in JWindows.
What should I do ?
Type more carefully and a lot slower? :)

Do you mean "how do I capture key events that Swing/awt is eating"?
If so you need to create a key handler by extending KeyAdapter. You
probably only need to override the keyTyped method, which should
extract the keypress from the event and send it to your model.
Instantiate the key handler in your JWindow constructor and call
addKeyListener() (inherited from java.awt.Component) to install it.
 
A

Andrew Thompson

Mahdi said:
I can't control key events in JWindows.

Have you tried using (or threatening) capital punishment?
That often scares key events into line.
What should I do ?

1. Post some (very short) compilable example of
your code that does not work.

2. Ensure you setFocusable(true) and requestFocus()
on the JWindow or its main component.

3. If 2. fails, ..see 1.

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Why JWindow can not catch the KEY Type event? 3
JWindow KeyListener 4
KeyListener 2
KeyListener 2
Help using Keylistener 4
KeyListener First Key Typed 3
Java Course issues 1
JTextField inactive in a JWindow 6

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top