有没有什么地方可以找到框架提供的 ActionMap 中 Action 的实际代码?

Is there anywhere we can find the actual code of the Actions in framework-supplied ActionMaps?

目前我特别感兴趣的是 JTable 的 'cancel' 操作...特别是我试图找出原因,为 JTable 的 CellEditor 组件 (JTextField) 设置了 InputVerifier ,当我按下 Escape 时,IV 的 shouldYieldFocus() 方法不是被调用一次,而是被调用两次(!)。

我已经检查过它是 VK_CANCEL ('cancel') 的 JTable 的 ActionMap 条目,这里是 运行。

此外,我发现当我像这样按 Escape 时,JTable 的 editingCanceled 方法没有被调用...这反过来使得目前让 IV 知道正在发生取消操作有点困难(并且验证应该因此不被称为)。

当然创建我自己的 "Cancel" Action 很容易,它调用从 JTable 的 ActionMap 中获取的取消 Action,而且还设置了一个标记 "disregard the text of the JTF... we're cancelling"。但我只想看看取消操作实际上由什么组成...即代码。

以后
查看了一个或两个 类 的源代码,特别是 JComponent 和 AbstractCellEditor,似乎触发了 IV 的 shouldYieldFocus,也许并不奇怪,当请求取消焦点时。

我还没有解决我的具体问题,我仍然想知道是否可以找到这些ActionMap Actions的代码...

是的。正如所讨论的 here, and illustrated here, subclasses of TextAction are installed as key bindings by the text component's UI delegate, typically a subclass of BasicTextUI. Each Action is typically an instance of a class nested in the relevant editor kit. For example, DefaultEditorKit includes several public actions, as well as a larger number of package-private 内部使用的操作。

可以在 JTable UI 委托中找到名为 "cancel"Action 的处理程序,通常是 BasicTableUI 的子类.

Validating Input, ensure that your implementation of verify() has no side effects. A complete example is examined here. Examples using an InputVerifier in a TableCellEditor are seen here and here 所述。

通过 com.apple.laf.AquaLookAndFeel:

WHEN_FOCUSED 绑定到 JTextField 的操作和键
beep:
caret-backward: LEFT, KP_LEFT, ctrl B
caret-begin: ctrl P, meta UP, meta KP_UP, HOME
caret-begin-line: KP_UP, ctrl A, UP, meta KP_LEFT, meta LEFT
caret-begin-paragraph:
caret-begin-word:
caret-down:
caret-end: ctrl N, END, meta KP_DOWN, ctrl V, meta DOWN
caret-end-line: DOWN, meta KP_RIGHT, ctrl E, meta RIGHT, KP_DOWN
caret-end-paragraph:
caret-end-word:
caret-forward: RIGHT, ctrl F, KP_RIGHT
caret-next-word: alt KP_RIGHT, alt RIGHT
caret-previous-word: alt KP_LEFT, alt LEFT
caret-up:
copy:
copy-to-clipboard: meta C, COPY
cut:
cut-to-clipboard: CUT, meta X
default-typed:
delete-next: DELETE, ctrl D
delete-next-word: alt DELETE
delete-previous: BACK_SPACE, ctrl H
delete-previous-word: alt BACK_SPACE, ctrl W
dump-model:
insert-break:
insert-content:
insert-tab:
notify-field-accept: ENTER
page-down:
page-up:
paste:
paste-from-clipboard: meta V, PASTE
requestFocus:
select-all: meta A
select-line:
select-paragraph:
select-word:
selection-backward: shift LEFT, shift KP_LEFT
selection-begin: shift meta KP_UP, shift meta UP, shift HOME
selection-begin-line: shift UP, shift meta KP_LEFT, shift KP_UP, shift meta LEFT
selection-begin-paragraph:
selection-begin-word:
selection-down:
selection-end: shift meta DOWN, shift meta KP_DOWN, shift END
selection-end-line: shift meta KP_RIGHT, shift DOWN, shift KP_DOWN, shift meta RIGHT
selection-end-paragraph:
selection-end-word:
selection-forward: shift KP_RIGHT, shift RIGHT
selection-next-word: shift alt KP_RIGHT, shift alt RIGHT
selection-page-down: shift PAGE_DOWN
selection-page-left: shift meta PAGE_UP
selection-page-right: shift meta PAGE_DOWN
selection-page-up: shift PAGE_UP
selection-previous-word: shift alt LEFT, shift alt KP_LEFT
selection-up:
set-read-only:
set-writable:
toggle-componentOrientation: shift ctrl O
unselect: meta BACK_SLASH