java - 在 CaretListener 中获取变量(如 getActionCommand)
问题描述
当我的 JTextFiled 更新时,我想将一个变量传递给 CaretListener。
多亏了“caretUpdate”,我的听众才能完美地工作。
但是,当我使用“actionPerformed”时,我不知道如何将变量传递给我的“caretUpdate”,例如“e.getActionCommand()”,但“caretUpdate”似乎不存在,有解决方案吗?
编辑:在我看来,我有一个 textField 女巫附加到听众:
textField.setActionCommand("test");
textField.addCaretListener(this.controller);
在我的控制器中,我有监听器,我想获得值 "test" :
public void caretUpdate(CaretEvent e) {
// here I want to get the "test" value
String maVar = e.getActionCommand();
}
但是 CaretEvent 不存在 e.getActionCommand()。有替代方案吗?
解决方案
推荐阅读
- python - conda 是否删除了我的 crontab 文件和我的 selenium 模块?
- react-native - 在 React Native 中,我可以将状态设置为 api 调用中的对象吗?
- android - 模拟器在 Macbook pro 上的 Android Studio 中启动时显示快速保存对话框
- r - 使用 ftransform 和来自 collapse R 包的 fgroup_by
- django - 过滤类别 Django
- oracle - 使用传递给过程的动态表名立即执行
- ruby - YARD::Handlers::Ruby::AttributeHandler: 无法记录的警告
- android - ImageAnalyzer ML Kit 边界框错列
- python - 熊猫数据框
- javascript - 在渲染之前对字符串的特定部分做出反应?