java - How to prevent multiple clicks on JComboBox -
I try to implement the mechanism, which is the number of clicks (I popup listener on For example: 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: Usually to avoid duplicate event firing during the event handling process, we can follow the steps given below: I'm giving you a skeleton example with Pocketton your reference. Example: Hope this will help you. Regards, Marais JComboBox Uses) and prevents the incident being included for the audience.
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}}}}
< 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)
Submit JButton submit = New Pocket (...). Exclamation (this); ... click on public zero actions (...) {//} submit.removeActionListener (); // Submit business logic. AddActionListener (this); }
Comments
Post a Comment