• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing private data in AWTEvent class

 
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks,

I need to access private variable 'bdata[]' which is inside java.awt.AWTEvent abstract class.

I am trying a multilingual program which requires input from all kinds of keyboard (i.e.,) Japanese,Chinese.. etc. When i was trying with Japanese keyboard i found that for some special keys i am not able to detect those keys by extending KeyEvent class in my inner class

<blockquote>code:
<pre name="code" class="core">

class MyKeyListener extends KeyEvent {

public void keyPressed(KeyEvent e)
{
System.out.println ("Keyevent pressed");
}
public void keyReleased(KeyEvent e)
{
System.out.println ("Keyevent released");
}
}
</pre>
</blockquote>

I am using eclipse for my development purpose.When i try to debug using Eclipse i can able to see the value of bdata[] array.How to access that bdata[] in AWTEvent class using Java code to get scan code for my Key Inputs.


Thanks in advance
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's in that array? I'm looking at the source of AWTEvent, and it doesn't seem to get used. Maybe there's some other way to accomplish this.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me get this straight.

You want access to a private field.
Which has no documentation in the source code.
Which is not used in Java code, only possibly in native code.

Now my question is: why?? Are you sure that accessing this field will help you? Are you even sure that you know what is actually in this field?
 
Balasubramanian Chandrasekaran
Ranch Hand
Posts: 215
Firefox Browser VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reply for Ulf Dittmer,

What's in that array?
I can see keyboard scan code which gets stored in that byte array.This one you can verify by placing a breakpoint inside MyKeyListener inner class which i posted in my initial post and Debug it using Eclipse and once the control reaches there i can [i]Right click on Object reference 'e' for KeyEvent and select Inspect Option which shows that bdata private field values. This is how i figured out that it contains some value which i need in my program.

Maybe there's some other way to accomplish this
What is the other way, can you explain in brief.

Reply for Rob Prime,

why?
There are some special keys in Japanese keyboard which is not recognized by KeyEvent it gives value as 0(zero).But, that bdata array which i quoted earlier contains keyboard scan code values which i can see using Debug option under Eclipse editor.

Are you sure that accessing this field will help you?
Ya i am sure that accessing bdata field is useful.As i already seen scan code gets stored in that field.

what is actually in this field?
When i checked, it contains keyboard scan code values in that byte array.

Expecting your reply...
 
Balasubramanian Chandrasekaran
Ranch Hand
Posts: 215
Firefox Browser VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally i got the method to read bdata by using reflections,

I will post my solution here.
reply
    Bookmark Topic Watch Topic
  • New Topic