Java MouseListener for ComboBox [英] Java MouseListener for ComboBox

查看:153
本文介绍了Java MouseListener for ComboBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何向 ComboBox 中添加 MouseListener ?我试过:

How do I add a MouseListener to a ComboBox? I have tried:

comboBox.addMouseListener(new MouseAdapter() { 
    public void mousePressed(MouseEvent event) {
        System.out.println("ok");   
    }

    public void mouseReleased(MouseEvent event) {
        System.out.println("ok");   
    }
});

似乎不行。我需要让程序做一些事情,当我按下 ComboBox ,例如,因为它是可编辑的输入。

It doesn't seems to work. I need to make the program do something when I press on the ComboBox, for example for typing because it is editable.

推荐答案

对于基本挥杆相关问题(我假设你在这里使用挥杆),检查 Java教程

For basic swing related questions (I assume you use swing here), check the swing trail of the Java tutorial.

这篇关于Java MouseListener for ComboBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆