我们可以在任何地方找到框架提供的ActionMap中Action的实际代码吗? [英] Is there anywhere we can find the actual code of the Actions in framework-supplied ActionMaps?

查看:63
本文介绍了我们可以在任何地方找到框架提供的ActionMap中Action的实际代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此刻我最感兴趣的是JTable的取消"操作……特别是我试图找出为什么为JTable的CellEditor的Component(JTextField)设置了InputVerifier的情况下,IV的shouldYieldFocus ()方法不是一次调用,而是在按Escape键时两次调用(!).

The particular thing I'm interested in at the moment is JTable's 'cancel' Action ... in particular I'm trying to find out why, with an InputVerifier set for the JTable's CellEditor's Component (JTextField), the IV's shouldYieldFocus() method is called not once, but twice (!) when I press Escape.

我已经检查了它是JTable的VK_CANCEL('cancel')的ActionMap条目,该条目正在此处运行.

I have checked that it is the JTable's ActionMap entry for VK_CANCEL ('cancel') which is being run here.

此外,我发现当我按这样的Escape键时,未调用JTable的editedCanceled方法...这反过来使当前很难让IV知道正在发生取消动作(因此,验证不应该这样做)被称为).

Furthermore I find that the JTable's editingCanceled method is NOT called when I press Escape like this... and this in turn makes is slightly difficult currently to let the IV know that a cancellation action is happening (and that verify should not therefore be called).

当然,创建我自己的取消"动作很容易,该动作调用从JTable的ActionMap获得的cancel动作,而且还设置了一个标记,表示忽略JTF的文本...我们要取消".但是我只想看看取消动作实际上是由什么组成的...即代码.

Of course it's easy enough to create my own "Cancel" Action, which calls the cancel Action obtained from the JTable's ActionMap, but also sets a flag saying "disregard the text of the JTF... we're cancelling". But I'd just like to see what the cancellation Action actually consist of... i.e. the code.

以后
在查看了一个或两个类的源代码之后,尤其是JComponent和AbstractCellEditor,看来当提出将焦点移走的请求时,IV的shouldYieldFocus被触发了,也许并不奇怪.

later
Having had a look at the source code for one or two classes, in particular JComponent and AbstractCellEditor, it appears that the IV's shouldYieldFocus is triggered, perhaps not that surprisingly, when a request to take focus away is made.

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

I haven't yet solved my specific problem, and I'd still like to know if it's possible to find the code of these ActionMap Actions...

推荐答案

是.如此处所述,并说明了 通过键绑定安装文本组件的UI委托,通常是 BasicTextUI .每个Action通常是嵌套在相关编辑器工具包中的类的实例.例如, DefaultEditorKit 包括几个public操作,以及大量的 package-private 操作.

Yes. As discussed 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 actions used internally.

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

The handler for the Action named "cancel" may be found, among others, in the JTable UI delegate, typically a subclass of BasicTableUI.

验证输入 ,请确保您的verify()实现没有副作用.在此处中检查了一个完整的示例.在此处TableCellEditor中使用InputVerifier的示例. com/a/13510756/230513>此处.

As noted in 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.AquaLookAndFeelWHEN_FOCUSED绑定到JTextField的动作和键:

Actions and keys bound WHEN_FOCUSED to JTextField by com.apple.laf.AquaLookAndFeel:

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

这篇关于我们可以在任何地方找到框架提供的ActionMap中Action的实际代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆