Node中的explorer views的双击事件

重写getPreferredAction()方法即可

public class UserNode extends AbstractNode {
    
    public UserNode(PeerInfo peerInfo) {
        super(Children.LEAF, Lookups.singleton(peerInfo));
        
        this.setName(peerInfo.getPeerID());
        this.setDisplayName(peerInfo.getName());
    }
    
    @Override
    public Action[] getActions (boolean popup) {
        
        return new Action[] {new ChatAction()};
    }

    @Override
    public Action getPreferredAction() {
        return new ChatAction();
    }
}
原文地址:https://www.cnblogs.com/cuizhf/p/2186259.html