File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Accessing private data in AWTEvent class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Accessing private data in AWTEvent class" Watch "Accessing private data in AWTEvent class" New topic
Author

Accessing private data in AWTEvent class

Balasubramanian Chandrasekaran
Ranch Hand

Joined: Nov 28, 2007
Posts: 215

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
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
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.


Ping & DNS - updated with new look and Ping home screen widget
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

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?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Balasubramanian Chandrasekaran
Ranch Hand

Joined: Nov 28, 2007
Posts: 215

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

Joined: Nov 28, 2007
Posts: 215

Finally i got the method to read bdata by using reflections,

I will post my solution here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing private data in AWTEvent class
 
Similar Threads
protected access question
Run a ProC or C file from Java
Unable to send simple mail using java mail api
Static initialization block?????
EJB QL & heterogeneous relationships