gpt4 book ai didi

java - 如何在 TreeSelectionEvent 中仅设置左键单击

转载 作者:行者123 更新时间:2023-12-02 07:38:29 24 4
gpt4 key购买 nike

我在 jtree 中编写了用于方法单击的代码,但我只想在左键单击中执行该操作

class SelectionListener  extends DefaultMutableTreeNode implements TreeSelectionListener {
public void valueChanged(TreeSelectionEvent se) {...}

最佳答案

如果您正在捕获MouseEvent,那么您可以使用以下方法来检查单击是否为左键单击:

SwingUtilities.isLeftMouseButton(mouseEvent)

关于java - 如何在 TreeSelectionEvent 中仅设置左键单击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11894818/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com