首页 > 解决方案 > 如何使用鼠标单击事件停止或继续循环?

问题描述

我有一个 java 小程序,它有一个类,它有一个 for 循环。我想要的是当我用鼠标单击事件点击“下一个”按钮时该循环停止,简而言之,我如何停止或继续循环捕获与循环不同类的按钮的 mouseevent ? ,那条件会怎样?你能举个例子吗,因为我的代码还没有完成,我不知道我该怎么做。非常感谢。

PM(boolean opcNotes[], int numtries){
Sonido sonido=new Sonido[opcNotes[].length];
for(int i=0;i<sonido.length;i++){
    sonido[i]=sonido.generateSound[opcNotes];}
for(int i<0;i<sonido.length;i++){

    sonido[i].play();
    for(int j=0;j<numtries;j++){

       if(){continue;}     //If i press the "next" button, ill go to the 
                           //next iteration

       else if(){         //If i press the "play again" button, ill do the
                          //action again
          numtries++;
          sonido[i]().play
          }
}

标签: javaswingmouseeventmouseclick-event

解决方案


推荐阅读