java - 如何使用文本 Action

标签 java swing action key-bindings jtextcomponent

使用TextAction的目的是什么?来自 AbstractAction ?以及如何将其用于以下用途:

最佳答案

来自 Java Swing 2nd Edition :

All text components share a set of default Actions. Each of these Actions are instances of TextAction by default. JTextComponent provides a private static EditorKit which consists of a set of four pre-built TextActions shared by all text components through the use of a default Keymap instance.

JTextComponent maintains a private reference to the text component that most recently had the keyboard focus. TextActions are designed to take advantage of this, and each TextAction will operate on this component when it’s invoked in the event that the source of the invoking event is not a text component.

下面是一些实现 TextAction 的例子:

Custom Editing Command

Finding Word Boundaries

关于java - 如何使用文本 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10075147/

相关文章:

asp.net-mvc-3 - MVC 自定义操作属性

javascript - 使用javascript访问不同页面上的表单元素

java - BufferedWriter 停止写入

java - 对多个属性使用 Spring @Value 注解

java - CardLayout - 定位组件

java - 在 CellRenderer 中显示选定的行和列

java - 事务的 Spring 自注入(inject)

java - 如何让我的程序根据特定情况重复执行?

java - JTabbedPane:在选项卡中显示任务进度

ios - 获得异常,即使我不应该使用 UIButton