Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

keyListener in JWindow

Thread view: 
Mahdi Dabestani - 22 Jul 2006 20:12 GMT
I can't control key events in JWindows.
What should I do ?
Martin Gregorie - 22 Jul 2006 23:16 GMT
> 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.

Signature

martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

Andrew Thompson - 22 Jul 2006 23:29 GMT
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.