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!

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

Hello,

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){
continueMyProgram();
}

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

}
}

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

Hello Best,

That was very helpful! Thanks a lot!

Regards

So do you need any more help? If not mark the thread as solved

Hello,

No. Thanks. Will do.

Regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.