Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > class implements KeyListener in Java

class implements KeyListener in Java
Thread Tools
Fresh-Faced Recruit
Join Date: May 2001
Location: Chicago
Status: Offline
Reply With Quote
May 5, 2001, 12:12 PM
 
Hello, I have written a simple program to test KeyEvent and I am having problems. I have created a class that extends JWindow and implements the KeyListener interface, but the JWindow does not seem to ever accept events of any kind. I originally wrote the program at work using WindowsNT and JDK 1.3 and all is good, but when I compile it using ProjectBuilder or command line java in OS X (10.0.2) there are no events registered. Is there a finer point to the OSX event model that I am missing, or is this a bug?

------------------
biome
biome
     
Fresh-Faced Recruit
Join Date: Mar 2001
Location: Dixon, Ca
Status: Offline
Reply With Quote
May 14, 2001, 04:32 PM
 
This appears to be a bug in the Java2 implementation on Mac OS X. The best guess is that it's a focus issue that in the past has shown up on unix-based implementations, such as Solaris and Linux. My suspicion is that the Mac OS X implementation is similarly afflicted.

You CAN however get this to work properly with a bit of a hack. I created a test case that has a JFrame as well as a JWindow subclass that implements BOTH KeyListener and MouseListener. You must make the JFrame visible, but you can make it visible off-screen if you wish. I've also had to call requestFocus() in all the MouseListener methods or KeyEvents were still not received.

The test code is a bit long (about 100 lines) so I'd prefer not to post it, but if you'd like me to email just say the word.
So they cloned a sheep - who could tell the difference anyway? - Robin Williams
     
Fresh-Faced Recruit
Join Date: May 2001
Location: Chicago
Status: Offline
Reply With Quote
May 14, 2001, 06:06 PM
 
Thanks, I needed to know if other people had seen this type of thing. I agree with you that it seems to be a focus problem, and I would like to take a look at the code you've got if it's not to much trouble. My e-mail is boime@interaccess.com

I also just learned that Apple is not supporting the Java3D API quite yet, so this puts a crimp in the project running in Java with true cross platform support. I am considering writing it in C++ now, but it's going to be quite a bit more work writing for Windows and MacOS X than it would have been just using Java. Aplle growing pains I guess. Thanks again.

Tim
biome
     
   
Thread Tools
Forum Links
Forum 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 On
Top
Privacy Policy
All times are GMT -5. The time now is 09:58 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2