java - Combining JMenu clipboard functions, accelerators, and actionMenu support (best practices) -


i've got component several jtables on it. i've installed custom transferhandlers on tables. now, want means invoke cut/copy/paste commands on these tables, via:

  1. the menubar, works on focused jtable
  2. popup menu on jtables
  3. keyboard shortcut, works on focused jtable

jtable's actionmap has entries "cut", "copy", "paste". actions these keys correct thing, invoking transferhandler.

i've tried following:

datatable.getinputmap(jcomponent.when_ancestor_of_focused_component).put(cutmenuitem.getaccelerator(), "cut"); 

this works when press cmd-x, not when select "cut" menu. assume because menu consumes event, , never gets jtable.

i can think of several hacky ways implement this, there clean way go it? how can menu items send actioncommand focused component?

it's not clear how initializing menu items. jtable not 1 of text components, may want @ ccp in non-text component regard setting edit menu.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -