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 / First Aid / January 2008

Tip: Looking for answers? Try searching our database.

KeyEvent.getKeyText won't show keys since Leopard/Intel

Thread view: 
Miss Elaine Eos - 26 Jan 2008 02:51 GMT
I recently switched from PPC 10.4.11 (Tiger) to Intel/Leopard.

A project of mine has code like this:

  protected   void  processAWTEvents (AWTEvent[] evt)
  {
     for (int ii = 0 ; ii < evt.length ; ++ii)
     {
        if (evt [ii] instanceof KeyEvent)
        {
           int      type  = evt [ii].getID();
           int      code  = ((KeyEvent) evt [ii]).getKeyCode();
           String   text  = KeyEvent.getKeyText (code);

               System.out.println ("type  : " + type);
               System.out.println ("  code: " + code);
               System.out.println ("  text: " + text);
        [... etc.]

This function is called (by Java3D) every time a key is pressed.  So
far, so good.

On my PPC/Tiger system, the println(text) would show things like
"LEFT_ARROW" and "SHIFT_KEY", etc. for those keys.

On my Intel/Leopard system, I get this:

[Session started at 2008-01-25 18:50:00 -0800.]
Pigs!
type  : 401             // (401 = keydown)
 code: 32
 text: ?               // <space>
type  : 400             // 400 = key-repeat?  Key-typed?  Whatever...
 code: 0
 text: Unknown keyCode: 0x0
type  : 402             // (402 = keyup)
 code: 32
 text: ?
type  : 401
 code: 37              // left arrow
 text: ?
type  : 402
 code: 37
 text: ?
type  : 401
 code: 39              // right arrow
 text: ?
type  : 402
 code: 39
 text: ?
type  : 401
 code: 38              // up arrow
 text: ?
type  : 402
 code: 38
 text: ?
type  : 401
 code: 40              // down arrow
 text: ?
type  : 402
 code: 40
 text: ?
type  : 401             // various meta keys follow...
 code: 16              // shift, cntl, CMD, fn, etc.
 text: ?
type  : 402
 code: 16
 text: ?
type  : 401
 code: 157
 text: ?
type  : 402
 code: 157
 text: ?
type  : 401
 code: 18
 text: ?
type  : 402
 code: 18
 text: ?
type  : 401
 code: 17
 text: ?
type  : 402
 code: 17
 text: ?

Any ideas what happened, and how I can fix it?

Thanks!

Signature

Please take off your pants or I won't read your e-mail.
I will not, no matter how "good" the deal, patronise any business which sends
unsolicited commercial e-mail or that advertises in discussion newsgroups.

Daniele Futtorovic - 28 Jan 2008 20:12 GMT
> I recently switched from PPC 10.4.11 (Tiger) to Intel/Leopard.
>
[quoted text clipped - 6 lines]
>
> Any ideas what happened, and how I can fix it?

According to the doc for KeyEvent#getKeyText:
    "Returns a String describing the keyCode, such as "HOME", "F1" or
"A". These strings can be localized by changing the awt.properties file."

Sounds like your problem is with the distributor of your JRE/SDK.

DF.

Signature

Can I put my pants back on now?



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.