e856. 列出一个组件的所有事件
This example demonstrates how to list all the actions in a component.
ActionMap map = component.getActionMap();
// List actions in the component
list(map, map.keys());
// List actions in the component and in all parent action maps
list(map, map.allKeys());
public static void list(ActionMap map, Object[] actionKeys) {
if (actionKeys == null) {
return;
}
for (int i=0; i<actionKeys.length; i++) {
// Get the action bound to this action key
while (map.get(actionKeys[i]) == null) {
map = map.getParent();
}
Action action = (Action)map.get(actionKeys[i]);
}
}
A text component not only has an action map with actions, it also has keymaps with actions. Moreover, every keymap has a default action to handle any typed character key events not handled by any input map or keymap. The following code retrieves actions from these objects:
// List the actions in the keymaps
if (component instanceof JTextComponent) {
JTextComponent textComp = (JTextComponent)component;
Keymap keymap = textComp.getKeymap(); while (keymap != null) {
// Get actions in the keymap
Action[] actions = keymap.getBoundActions();
for (int i=0; i<actions.length; i++) {
Action action = actions[i];
} // Get the default action in the keymap
Action defaultAction = keymap.getDefaultAction();
keymap = keymap.getResolveParent();
}
}
| Related Examples |
e856. 列出一个组件的所有事件的更多相关文章
- Vue中调用另一个组件中自定义事件
之前在一个场景中,遇到组件需要调用父组件中的方法tableInit(),字组件调用父组件常用的有三种方法,具体参考:https://www.cnblogs.com/jin-zhe/p/9523782. ...
- Vue一个案例引发的动态组件与全局事件绑定总结
最近在自学 Vue 也了解了一些基本用法,也记录了一些笔记有兴趣的朋友可以去查看我的其他文章,技术这东西真的不能光靠看,看是没有的,你必须要动手实践,只有在实战项目中才能发现问题,才能发现我们没有掌握 ...
- 微信小程序开发03-这是一个组件
编写组件 基本结构 接上文:微信小程序开发02-小程序基本介绍 我们今天先来实现这个弹出层: 之前这个组件是一个容器类组件,弹出层可设置载入的html结构,然后再设置各种事件即可,这种组件有一个特点: ...
- bootstrap中的dropdown组件扩展hover事件
bootstrap的下拉组件,需要点击click时,方可展示下拉列表.因此对于喜欢简单少操作的大家来说,点击一下多少带来不便,因此,引入hover监听,鼠标经过自动展示下拉框.其实在bootstrap ...
- vue子组件的自定义事件
父子组件的信息传递无碍就是父组件给子组件传值(props和$attrs)和父组件触发子组件的事件($emit) 之前已经谈过了父组件给子组件传值了,现在来说说父组件触发子组件的自定义事件吧-- 实际上 ...
- vuejs组件交互 - 02 - 事件中心管理组件间的通信
事件中心 这个可以是一个空的全局的Vue实例,其他的组件利用这个实例emit和on自定义事件,这样组件定义了自己的事件处理方法. import Vue from 'Vue' window.eventH ...
- vue如何正确销毁当前组件的scroll事件?
将方法写出来,销毁在beforeDestroy写. mounted(){ window.addEventListener("scroll",this.handleFun), }, ...
- Vue.js教程--基础(实例 模版语法template computed, watch v-if, v-show v-for, 一个组件的v-for.)
官网:https://cn.vuejs.org/v2/guide/index.html Vue.js 的核心是一个允许采用简洁的模板语法来声明式地将数据渲染进 DOM 的系统. 视频教程:https: ...
- NO.08--VUE之自定义组件添加原生事件
前几篇给大家分享了我的业余的“薅羊毛”的经历,回归正题,讲回vue吧: 许多vue新手在工作开发中会遇到一个问题,直接使用 button 添加原生事件是没有问题的,但是使用自定义组件添加原生事件时,就 ...
随机推荐
- spark on alluxio和MR on alluxio测试(改进版)【转】
转自:http://kaimingwan.com/post/alluxio/spark-on-alluxiohe-mr-on-alluxioce-shi-gai-jin-ban 1. 介绍 2. 准备 ...
- 【教程】ubuntu下配置nvc详细教程
Preface 虽然以前在windows上远控linux都是用的FTP+CRT,不过有些时候还是不太方便,比如不能用IDE对程序进行调试,现在就来配置下VNC,过程中出了些错误,上网查询时发现很多解决 ...
- 多媒体文件格式之ASF
[时间:2016-06] [状态:Open] ASF,全称Advanced Systems Format,是由微软提出的开放封装格式标准.ASF是微软公司Windows Media的核心.这是一种包含 ...
- FFmpeg Basic学习笔记(3)
视频叠加--画中画效果 overlay video filter 视频叠加比较常见的应用场景是台标的叠加,在画面左上角.右上角.左下角或右下角叠加台标. ffmpeg提供的overlay filter ...
- nginx源码分析:打开监听套接字的流程
问题源于在分析nginx的源码时,找了半天没有找到nginx是怎么把监听套接字读事件添加到事件循环中的,后经过仔细的分析,终于搞明白,于是记录一下. 在上一篇module机制中介绍了nginx添加mo ...
- 【转】31个实用的find命令
find . -name "*.sql" -exec md5sum {} \; 一.主要内容 ====================================== . 用文 ...
- 【Turing Award】Robin Milner And Butler W. Lampson
1991 罗宾·米尔纳(Robin Milner) Robin Milner(13 January 1934 – 20 March 2010) Introduction : Milner was bo ...
- 管理 python logging 日志使用
1.日志级别 日志一共分成5个等级,从低到高分别是:DEBUG INFO WARNING ERROR CRITICAL. DEBUG:详细的信息,通常只出现在诊断问题上INFO:确认一切按预期运行WA ...
- 1. AutoEncoder介绍
1. AutoEncoder介绍 2. Applications of AutoEncoder in NLP 3. Recursive Autoencoder(递归自动编码器) 4. Stacked ...
- 基于jQuery环形图标菜单旋转切换特效
分享一款基于jQuery环形图标旋转切换特效.这是一款鼠标点击图标菜单圆形顺时针或者逆时针旋转切换代码.效果图如下: 在线预览 源码下载 实现的代码. js代码: /* 图片地址可以是相对路径或绝 ...