JTextComponent.KeyBinding[] newBindings = {
new JTextComponent.KeyBinding(
KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK),
DefaultEditorKit.beepAction),
new JTextComponent.KeyBinding(
KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK),
DefaultEditorKit.beepAction),
new JTextComponent.KeyBinding(
KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK),
DefaultEditorKit.beepAction)
};
Keymap k = documentTextPane.getKeymap();
JTextComponent.loadKeymap(k, newBindings, documentTextPane.getActions());
Block Key input in JTextComponet
@Override
protected void processKeyEvent(KeyEvent e) {
int kc = e.getKeyCode();
if (kc == KeyEvent.VK_HOME || kc == KeyEvent.VK_END
|| kc == KeyEvent.VK_PAGE_UP || kc == KeyEvent.VK_PAGE_DOWN
|| kc == KeyEvent.VK_UP || kc == KeyEvent.VK_DOWN
|| kc == KeyEvent.VK_LEFT || kc == KeyEvent.VK_RIGHT
|| kc == KeyEvent.CTRL_MASK || kc == KeyEvent.VK_C) {
super.processKeyEvent(e);
} else {
e.consume();
}
}