Hi,

In VB i know how to change the value of KeyAscii in KeyPress method of a textbox.

How can i do that in Java for a JTextField. I'm a newbie in Java

What i want is this:
User press Ctrl + Alt + Shift + B. After pressing this combination i want that for example an A is send to the JTextField.
or
User press Ctrl + Shift + D. After pressing this combination i want that for example an Z is send to the JTextField.

I tried to generate a New KeyEvent, but it doesn't do anything.
Here is a piece of code i tried:
Who can help me?


== class UpperCaseTextArea ==
import java.awt.AWTEvent;
import java.awt.TextArea;
import java.awt.event.KeyEvent;

public class UpperCaseTextArea
extends TextArea
{

public UpperCaseTextArea ()
{
enableEvents (AWTEvent.KEY_EVENT_MASK);
}

public void processKeyEvent (KeyEvent e)
{
if ( (e.getID () == KeyEvent.KEY_PRESSED))
{
if (e.isAltDown() && e.isControlDown() && e.isShiftDown())
{
KeyEvent nke = new KeyEvent(
e.getComponent() ,
e.getID(),
e.getWhen(),
e.getModifiers()
,66 //show a B
,kar
,e.getKeyLocation());

// consume old event
e.consume ();

super.processKeyEvent(nke);
}
else
{
super.processKeyEvent (e);
}
}
}
}


== class UCTextAreaTest ==

import java.awt.Frame;
import java.awt.BorderLayout;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class UCTextAreaTest {

public static void main(String[] args) {
Frame f = new Frame();
f.add(new UpperCaseTextArea(), BorderLayout.CENTER);
f.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
);
f.setSize(200, 150);
f.setVisible(true);
}
}


Thanks,

Anand