java - Platform specific cut paste mnemonics swing. -


i'm developing own text-like jcomponent. isn't subclass of jtextcomponent, because isn't using document model. i'd still support standard mnemonics of cut/copy/paste, know keystrokes depend on platform.

ultimately, i'll let user edit keybindings themselves, now, i'd @ least default sensible.

is possible lookandfeel somehow? or need detect platform myself , have mapping per platform?

i'm using java 8 if makes difference.

there no laf property i'm aware of purpose.

however might able use information inputmap of laf. following works windows 8:

import java.awt.*; import javax.swing.*;  public class platformmnemonics {     public static void main(string[] args)     {         keystroke copykeystroke = null;         keystroke cutkeystroke = null;         keystroke pastekeystroke = null;          inputmap im = (inputmap) uimanager.get("textfield.focusinputmap");          (keystroke keystroke: im.keys())         {             boolean uppercase = character.isuppercase( keystroke.getkeycode() );              if ( uppercase )             {                 string actionmapkey = im.get( keystroke ).tostring();                  if ("copy-to-clipboard".equals(actionmapkey))                     copykeystroke = keystroke;                 else if ("cut-to-clipboard".equals(actionmapkey))                     cutkeystroke = keystroke;                 else if ("paste-from-clipboard".equals(actionmapkey))                     pastekeystroke = keystroke;              }         }          system.out.println("copy  keystroke: " + copykeystroke);         system.out.println("cut   keystroke: " + cutkeystroke);         system.out.println("paste keystroke: " + pastekeystroke);     } } 

note there 3 bindings on windows each action can see in key bindings programs displays key bindings every swing component. displayed binding think interested in.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -