开发者

Java MouseListener for ComboBox

开发者 https://www.devze.com 2023-03-23 11:00 出处:网络
How do I add a MouseListener to a ComboBox? I have tried: c开发者_运维问答omboBox.addMouseListener(new MouseAdapter() {

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

c开发者_运维问答omboBox.addMouseListener(new MouseAdapter() { 
    public void mousePressed(MouseEvent event) {
        System.out.println("ok");   
    }

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

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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消