Search code examples
javaswingjtextpanehotkeys

Swing. Default keybindings in JTextPane


Now I working on a C IDE. As it's main theme is Motif, and my problem is how to add default KeyStroke(Ctrl + C - copy, Ctrl + V - paste) to JTextPane. In Motif L&F, JTextPane doesn't react on these KeyStrokes. How to make it perform the desired actions on these keys.


Solution

  • This may help:

    JTextPane.setKeymap(
      JtextPane.getKeymap().addActionForKeyStroke(
        KeyEvent.VK_V, InputEvent.CTRL_MASK,DefaultEditorKit.CopyAction));