e783. 监听对JList中项双击和三击
2024-10-12 00:43:39
// Create a list
String[] items = {"A", "B", "C", "D"};
JList list = new JList(items); // Add a listener for mouse clicks
list.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
JList list = (JList)evt.getSource();
if (evt.getClickCount() == 2) { // Double-click
// Get item index
int index = list.locationToIndex(evt.getPoint());
} else if (evt.getClickCount() == 3) { // Triple-click
// Get item index
int index = list.locationToIndex(evt.getPoint()); // Note that this list will receive a double-click event before this triple-click event
}
}
});
Related Examples |
最新文章
- spring boot(五):spring data jpa的使用
- python的编码规范【摘】
- 【原创】WinForm 模态对话框
- x01.Lab.StoreApp: XP 停服,微软变脸
- 《JavaScript模式》第3章 字面量和构造函数
- 41. Unique Binary Search Trees &;&; Unique Binary Search Trees II
- LeetCode OJ-- String to Integer (atoi) **
- Cornerstone无法上传静态库文件(.a文件)
- VB读写INI文件的四个函数以及相关API详细说明
- Python计算机视觉3:模糊,平滑,去噪
- 虚拟键盘,移动web开发的痛
- HALF<;水题>;
- php 运算符and or &;&; || 的详解
- UWP中实现大爆炸效果(二)
- selenium+python启动浏览器出错,安装浏览器驱动
- spring4笔记----PropertyPlaceholderConfigurer 属性占位符配置器
- SwipeableFlatList 实现类似于QQ列表滑动
- python系统编程(八)
- Mybatlis SQL 注入与防范
- Linux 条件变量函数signal和wait补充
热门文章
- (原创)c++11改进我们的模式之改进观察者模式
- 每日英语:Patent Wars Erupt Again in Tech Sector
- ffmpeg转码参数设置
- 【转】suspend造成死锁
- 【Java】自动类型转换规则
- 软链接ln -s以及如何解决其产生“Too many levels of symbolic links ”的错误?
- How To Install Java with Apt-Get on Ubuntu 16.04
- django 部署,gunicorn、virtualenv、nginx
- WriteableBitmap/BitmapImage/MemoryStream/byte[]相互转换
- PHP判断当前页面是电脑登录,还是手机登录