JList 使用所有鼠标按钮选择项目

发布于 2024-07-20 07:52:51 字数 68 浏览 3 评论 0原文

我怎样才能制作一个 swing JList 以使用任何鼠标按钮而不只是左边的按钮来选择其项目?

谢谢!

how can i make a swing JList to have its items selected with any mousebutton not just the left one?

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

知足的幸福 2024-07-27 07:52:51

哦,刚刚发现这个函数,

            int s = list.locationToIndex(e.getPoint());
            list.setSelectedIndex(s);

当你在鼠标监听器中执行此操作时,它可以完成工作。

oh just found the function

            int s = list.locationToIndex(e.getPoint());
            list.setSelectedIndex(s);

when you do this in a mouselistener it does the job.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文