How to consume some keyEvent?

Advertisement
Why can't I disable the key A but keeping other key?
Here is my code.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class myDropZone extends JTextPane {
public myDropZone(){
super();
this.setMargin(new Insets(0,0,0,0));
public void processKeyEvent(KeyEvent e){  
if (e.getKeyCode()== java.awt.event.KeyEvent.VK_A){
e.consume();
else{
super.processKeyEvent( e );
Please give me your valuable advice.
Ivan
Advertisement

Replay

ok, I'v just implemented it, it woks!
I didn't know that the component send envents before processing it itself, I've learn a really useful thing.
In fact it is explicitly writed in the API of the InputEvent class:
Thanks a lot