Edgar Buchvalov
Edgar Buchvalov

Reputation: 257

Java MouseListener for ComboBox

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");   
    }
});

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.

Upvotes: 0

Views: 3102

Answers (1)

Alexander Rühl
Alexander Rühl

Reputation: 6939

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

Upvotes: 1

Related Questions