|
-
September 29th, 1999, 08:39 AM
#1
Adding MouseListener to a combobox
I have the following sample code to capture mouse events in a combobox.
import java.awt.event.*;
import javax.swing.*;
.
.
.
.
JComboBox comboObject = new JComboBox();
comboObject.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
//Execute some code
}
}
});
But nothing seems to be working. Is it because comboboxes do not listen to low_level events such as mouse, focus and key events ?
I want the drop_down list in the combobox to listen for mouse events. The problem is that when any item in the drop_down list is double_clicked the component present below the combobox gets invoked. i.e., if in a gridbaglayout you have the combobox placed above a Jlist then the Jlist's item gets selected when you double click in a combobox.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|