Hello Members,

I have a program with a lot of MouseListeners. The issue I am having is the program is ending even before I click. I tried using sleep and flags to pause the program without much success. Just wondering if there is way to get the program to pause, go through all the MouseListeners and then resume the program. Will invokeLater() work here? If yes, could you give me a simple illustration of how it works?

Thank you!

Edited by sciprog1: n/a

7 Years
Discussion Span
Last Post by sciprog1

maybe yes, maybe no, everything are shots to the dark

that very hard to speak aynthing, post runnable example (just&only) that's shows all above mentioned Object and Listeners,

ensure, otherwise waits for someone with magic globe



Korbel - Sorry, I am unable to understand your reply.

Can other members weigh in?

Thank you!


Can you post an example of the relevant portion of the code? And a bit of context as to what the code is supposed to do?


Hello don,

Thanks for the reply. It's on a different computer. I will retrieve it soon. Could you tell me will "invokeLater()" work for the problem I am trying to solve?

Thank you!


invokeLater() probably has nothing to do with the problem you are describing. You didn't really explain what you mean by "resuming the program after you go through all the MouseListeners". What does it mean to "go through all the MouseListeners"? MouseListener is an interface; it has several methods that respond to mouse events. Are you waiting until each of those methods gets called, then continuing your program afterwards? If so, you may want to declare some boolean variables that get set to "true" from within the corresponding MouseListener method. Once all of those variables are true, you can "continue your program" by calling a method from within the MouseListener method.

For example:

void mouseClicked(MouseEvent e){
if (all mouse methods have been called){

void continueMyProgram(){
//Put the rest of your program's code here!!!


References: http://download.oracle.com/javase/tutorial/uiswing/events/mouselistener.html

Edited by BestJewSinceJC: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.