java - How to prevent multiple clicks on JComboBox -


I try to implement the mechanism, which is the number of clicks (I popup listener on JComboBox Uses) and prevents the incident being included for the audience.

For example:

  Public square SomeClass {protected boolean semaphore = false; Public Zero InitComboBox () {JComboBox Target Controllerscombox = New JComboBox (); // Object targetControllersComboBox.addPopupMenuListener (New PopupMenuListener) {@Override Public Null popupMenuWillBecomeVisible (PopupMenuEvent event) {if (Semaphore == incorrect) {Semaphore = true // Here is semaphor // Here are some code // Semaphore = False; // released semaphor}}}}   

Before running the code in the popupListener I already executed before the popUplistener can execute the next popUplistener working from the user before Want to avoid run code in popupListener .. My example misfortune Can not help about this situation from anyone I can help to be very supportful

UPDATE: FOLLOW (MARIS) RESLOVE PROBLEM:

 < Code> @Override Public Zero popupMenuWillBecomeVisible (PopupMenuEvent event) {JComboBox told = (JComboBox) event.getSource (); comboBox.removePopupMenuListener (this); // Some code .... // Now the listener has been disabled and users Can not follow this listener till the next listener ComboBox.addPopupMenuListener (this); // After some code we add the listener again, the user can now use the listener again)    

Usually to avoid duplicate event firing during the event handling process, we can follow the steps given below:

  1. Add Event Listener to Widget
  2. Once the event has been recovered, event listener begging for the event handling
  3. One Bar event handling (business logic) has ended, add event listener

    I'm giving you a skeleton example with Pocketton your reference.

    Example:

      Submit JButton submit = New Pocket (...). Exclamation (this); ... click on public zero actions (...) {//} submit.removeActionListener (); // Submit business logic. AddActionListener (this); }   

    Hope this will help you.

    Regards,

    Marais

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -