35274

Java MouseListener for ComboBox

Question:

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.

Answer1:

For basic swing related questions (I assume you use swing here), check the swing trail of the <a href="http://download.oracle.com/javase/tutorial/uiswing/components/combobox.html" rel="nofollow">Java tutorial</a>.

Recommend

  • paintComponent does not paint correctly
  • Java, convert string to a RSA publicKey
  • Is it possible to start drag on mousePressed using java Swing DnD api?
  • GUI Making Arrays of Images that Move Using Mouse Event
  • NullPointerException at Graphics.drawOval [duplicate]
  • Add ActionEvent in Swing [closed]
  • java: Get row data from popupmenu actionListener event
  • How are multi-button presses handled in swing?
  • How to get a circle to move when you click on it in javascript?
  • Java inline class calling method in parent class
  • Export Java applet to .jar
  • transparent JDialog becomes opaque when dragging to second screen (ubuntu 14.04 with Cinnamon, java
  • Mouse event in Java
  • How to change icon image of button on mouse entered/mouse exit?
  • Can I create EventListener in AS3 from one Object and remove it from another Object?
  • Get back anonymous type [duplicate]
  • Add a TCombobox Column to a Firemonkey TGrid
  • Set comboBox to custom display format
  • How do you remove the JComboBox 'click and see dropdown' functionality?
  • If statement skipping right to else after being called once?
  • Reading a file into a multidimensional array
  • How can I set a binding to a Combox in a UserControl?
  • App restarts from wrong activity
  • AJAX Html Editor Extender upload image appearing blank
  • d3 v4 drag and drop with TypeScript
  • JQuery Internet Explorer and ajaxstop
  • Jetty Server not starting: Unable to establish loopback connection
  • Opengl-es onTouchEvents problem or a draw problem? [closed]
  • Validaiting emails with Net.Mail MailAddress
  • sending/ receiving email in Java
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • How does Linux kernel interrupt the application?
  • Linking SubReports Without LinkChild/LinkMaster
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?