Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > keyListener in JWindow

Reply
Thread Tools

keyListener in JWindow

 
 
Mahdi Dabestani
Guest
Posts: n/a
 
      07-22-2006
I can't control key events in JWindows.
What should I do ?

 
Reply With Quote
 
 
 
 
Martin Gregorie
Guest
Posts: n/a
 
      07-22-2006
Mahdi Dabestani wrote:
> 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.


--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      07-22-2006
Mahdi Dabestani wrote:
> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JWindow KeyListener Max Java 4 10-29-2005 04:24 AM
JWindow on the desktop Lee Java 3 10-06-2004 06:30 PM
Re: JWindow Handle mromarkhan@rogers.com Java 0 05-24-2004 12:31 AM
JWindow HELP! AJ Java 3 04-08-2004 08:25 PM
Using JWindow under Red Hat Linux 9 and Java 1.4.2 AJ Java 0 04-05-2004 02:13 PM



Advertisments